def _all_number_groups_remain_grouped(numobj, normalized_candidate, formatted_number_groups):
 from_index = 0
 if (numobj.country_code_source != CountryCodeSource.FROM_DEFAULT_COUNTRY):
  country_code = str(numobj.country_code)
  from_index = (normalized_candidate.find(country_code) + len(country_code))
 for (ii, formatted_number_group) in enumerate(formatted_number_groups):
  from_index = normalized_candidate.find(formatted_number_group, from_index)
  if (from_index < 0):
   return False
  from_index += len(formatted_number_group)
  if ((ii == 0) and (from_index < len(normalized_candidate))):
   region = region_code_for_country_code(numobj.country_code)
   if ((ndd_prefix_for_region(region, True) is not None) and normalized_candidate[from_index].isdigit()):
    nsn = national_significant_number(numobj)
    return normalized_candidate[(from_index - len(formatted_number_group)):].startswith(nsn)
 return (normalized_candidate[from_index:].find((numobj.extension or U_EMPTY_STRING)) != (-1))

def _all_number_groups_remain_grouped ( numobj , normalized_candidate , formatted_number_groups ) : from_index = 0 if ( numobj . country_code_source != CountryCodeSource . FROM_DEFAULT_COUNTRY ) : country_code = str ( numobj . country_code ) from_index = ( normalized_candidate . find ( country_code ) + len ( country_code ) ) for ( ii , formatted_number_group ) in enumerate ( formatted_number_groups ) : from_index = normalized_candidate . find ( formatted_number_group , from_index ) if ( from_index < 0 ) : return False from_index += len ( formatted_number_group ) if ( ( ii == 0 ) and ( from_index < len ( normalized_candidate ) ) ) : region = region_code_for_country_code ( numobj . country_code ) if ( ( ndd_prefix_for_region ( region , True ) is not None ) and normalized_candidate [ from_index ] . isdigit ( ) ) : nsn = national_significant_number ( numobj ) return normalized_candidate [ ( from_index - len ( formatted_number_group ) ) : ] . startswith ( nsn ) return ( normalized_candidate [ from_index : ] . find ( ( numobj . extension or U_EMPTY_STRING ) ) != ( - 1 ) )
returns true if the groups of digits found in our candidate phone number match our expectations .