def _region_code_for_short_number_from_region_list(numobj, region_codes):
 if (len(region_codes) == 0):
  return None
 elif (len(region_codes) == 1):
  return region_codes[0]
 national_number = national_significant_number(numobj)
 for region_code in region_codes:
  metadata = PhoneMetadata.short_metadata_for_region(region_code)
  if ((metadata is not None) and _is_number_matching_desc(national_number, metadata.short_code)):
   return region_code
 return None

def _region_code_for_short_number_from_region_list ( numobj , region_codes ) : if ( len ( region_codes ) == 0 ) : return None elif ( len ( region_codes ) == 1 ) : return region_codes [ 0 ] national_number = national_significant_number ( numobj ) for region_code in region_codes : metadata = PhoneMetadata . short_metadata_for_region ( region_code ) if ( ( metadata is not None ) and _is_number_matching_desc ( national_number , metadata . short_code ) ) : return region_code return None
helper method to get the region code for a given phone number .