def expected_cost(numobj):
 region_codes = region_codes_for_country_code(numobj.country_code)
 if (len(region_codes) == 0):
  return ShortNumberCost.UNKNOWN_COST
 if (len(region_codes) == 1):
  return expected_cost_for_region(numobj, region_codes[0])
 cost = ShortNumberCost.TOLL_FREE
 for region_code in region_codes:
  cost_for_region = expected_cost_for_region(numobj, region_code)
  if (cost_for_region == ShortNumberCost.PREMIUM_RATE):
   return ShortNumberCost.PREMIUM_RATE
  elif (cost_for_region == ShortNumberCost.UNKNOWN_COST):
   return ShortNumberCost.UNKNOWN_COST
  elif (cost_for_region == ShortNumberCost.STANDARD_RATE):
   if (cost != ShortNumberCost.UNKNOWN_COST):
    cost = ShortNumberCost.STANDARD_RATE
  elif (cost_for_region == ShortNumberCost.TOLL_FREE):
   pass
  else:
   raise Exception('Unrecognized cost for region: %s', cost_for_region)
 return cost

def expected_cost ( numobj ) : region_codes = region_codes_for_country_code ( numobj . country_code ) if ( len ( region_codes ) == 0 ) : return ShortNumberCost . UNKNOWN_COST if ( len ( region_codes ) == 1 ) : return expected_cost_for_region ( numobj , region_codes [ 0 ] ) cost = ShortNumberCost . TOLL_FREE for region_code in region_codes : cost_for_region = expected_cost_for_region ( numobj , region_code ) if ( cost_for_region == ShortNumberCost . PREMIUM_RATE ) : return ShortNumberCost . PREMIUM_RATE elif ( cost_for_region == ShortNumberCost . UNKNOWN_COST ) : return ShortNumberCost . UNKNOWN_COST elif ( cost_for_region == ShortNumberCost . STANDARD_RATE ) : if ( cost != ShortNumberCost . UNKNOWN_COST ) : cost = ShortNumberCost . STANDARD_RATE elif ( cost_for_region == ShortNumberCost . TOLL_FREE ) : pass else : raise Exception ( 'Unrecognized cost for region: %s' , cost_for_region ) return cost
gets the expected cost category of a short number .