EBookContacts.PhoneNumber¶
Fields¶
None
Methods¶
class  | 
  | 
class  | 
  | 
class  | 
  | 
class  | 
  | 
class  | 
  | 
class  | 
|
class  | 
  | 
  | 
|
  | 
|
  | 
|
  | 
|
  | 
Details¶
- class EBookContacts.PhoneNumber¶
 This opaque type describes a parsed phone number. It can be copied using
EBookContacts.PhoneNumber.copy(). To release it callEBookContacts.PhoneNumber.free().New in version 3.8.
- classmethod compare_strings(first_number, second_number)¶
 - Parameters:
 first_number (
str) – the firstEBookContacts.PhoneNumberto comparesecond_number (
str) – the secondEBookContacts.PhoneNumberto compare
- Raises:
 - Returns:
 The quality of matching for the two phone numbers.
- Return type:
 
Compares two phone numbers.
New in version 3.8.
- classmethod compare_strings_with_region(first_number, second_number, region_code)¶
 - Parameters:
 first_number (
str) – the firstEBookContacts.PhoneNumberto comparesecond_number (
str) – the secondEBookContacts.PhoneNumberto compareregion_code (
strorNone) – a two-letter country code, orNone
- Raises:
 - Returns:
 The quality of matching for the two phone numbers.
- Return type:
 
Compares two phone numbers within the context of region_code.
New in version 3.8.
- classmethod from_string(phone_number, region_code)¶
 - Parameters:
 - Raises:
 - Returns:
 a new
EBookContacts.PhoneNumberinstance on success, orNoneon error. CallEBookContacts.PhoneNumber.free() to release this instance.- Return type:
 
Parses the string passed in phone_number. Note that no validation is performed whether the recognized phone number is valid for a particular region.
The two-letter country code passed in region_code only is used if the phone_number is not written in international format. The application’s default region as returned by
EBookContacts.PhoneNumber.get_default_region() is used if region_code isNone.If the number is guaranteed to start with a ‘+’ followed by the country calling code, then “ZZ” can be passed for region_code.
New in version 3.8.
- classmethod get_country_code_for_region(region_code)¶
 - Parameters:
 region_code (
strorNone) – a two-letter country code, a locale name, orNone- Raises:
 - Returns:
 a valid country calling code, or zero if an unknown region code was passed.
- Return type:
 
Retrieves the preferred country calling code for region_code, e.g. 358 for “fi” or 1 for “en_USUTF-8”.
If
Noneis passed for region_code the default region as returned byEBookContacts.PhoneNumber.get_default_region() is used.New in version 3.8.
- classmethod get_default_region()¶
 - Raises:
 - Returns:
 a newly allocated string containing the current locale’s two-letter code for phone number parsing.
- Return type:
 
Retrieves the current two-letter country code that’s used by default for parsing phone numbers in
EBookContacts.PhoneNumber.from_string(). It can be useful to store this number before parsing a bigger number of phone numbers.The result of this functions depends on the current setup of the %LC_ADDRESS category: If that category provides a reasonable value for %_NL_ADDRESS_COUNTRY_AB2 this value is returned. Otherwise the locale name configured for %LC_ADDRESS is parsed.
New in version 3.8.
- classmethod is_supported()¶
 - 
Checks if phone number support is available. It is recommended to call this function before using any of the phone-utils functions to ensure that the required functionality is available, and to pick alternative mechanisms if needed.
New in version 3.8.
 
- compare(second_number)¶
 - Parameters:
 second_number (
EBookContacts.PhoneNumber) – the secondEBookContacts.PhoneNumberto compare- Returns:
 The quality of matching for the two phone numbers.
- Return type:
 
Compares two phone numbers.
New in version 3.8.
- copy()¶
 - Returns:
 A newly allocated
EBookContacts.PhoneNumberinstance. CallEBookContacts.PhoneNumber.free() to release this instance.- Return type:
 
Makes a copy of self.
New in version 3.8.
- free()¶
 Released the memory occupied by self.
New in version 3.8.
- get_country_code(source)¶
 - Parameters:
 source (
EBookContacts.PhoneNumberCountrySourceorNone) – an optional location for storing the phone number’s origin, orNone- Returns:
 A valid country calling code, or zero if no code is known.
- Return type:
 
Queries the self's country calling code and optionally stores the country calling code’s origin in source. For instance when parsing “+1-617-5423789” this function would return one and assign
EBookContacts.PhoneNumberCountrySource.FQTNto source.New in version 3.8.
- get_national_number()¶
 - Returns:
 The national portion of self.
- Return type:
 
Queries the national portion of self without any call-out prefixes. For instance when parsing “+1-617-5423789” this function would return the string “6175423789”.
New in version 3.8.
- to_string(format)¶
 - Parameters:
 format (
EBookContacts.PhoneNumberFormat) – the phone number format to apply- Returns:
 A formatted string for self.
- Return type:
 
Describes the self according to the rules applying to format.
New in version 3.8.