def _region_code_for_number_from_list(numobj, regions):
 national_number = national_significant_number(numobj)
 for region_code in regions:
  metadata = PhoneMetadata.metadata_for_region(region_code.upper(), None)
  if (metadata is None):
   continue
  if (metadata.leading_digits is not None):
   leading_digit_re = re.compile(metadata.leading_digits)
   match = leading_digit_re.match(national_number)
   if match:
    return region_code
  elif (_number_type_helper(national_number, metadata) != PhoneNumberType.UNKNOWN):
   return region_code
 return None

def _region_code_for_number_from_list ( numobj , regions ) : national_number = national_significant_number ( numobj ) for region_code in regions : metadata = PhoneMetadata . metadata_for_region ( region_code . upper ( ) , None ) if ( metadata is None ) : continue if ( metadata . leading_digits is not None ) : leading_digit_re = re . compile ( metadata . leading_digits ) match = leading_digit_re . match ( national_number ) if match : return region_code elif ( _number_type_helper ( national_number , metadata ) != PhoneNumberType . UNKNOWN ) : return region_code return None
find the region in a list that matches a number .