Python: module phonenumbers.carrier

phonenumbers.carrier | index phonenumbers/carrier.py

`Phone number to carrier mapping functionality
>>> import phonenumbers
>>> from phonenumbers.carrier import name_for_number
>>> ro_number = phonenumbers.parse("+40721234567", "RO")
>>> str(name_for_number(ro_number, "en"))
'Vodafone'
>>> str(name_for_number(ro_number, "fr")) # fall back to English
'Vodafone'`

Functions
`` |  | name_for_number(numobj, lang, script=None, region=None) `Returns a carrier name for the given PhoneNumber object, in the language provided. The carrier name is the one the number was originally allocated to, however if the country supports mobile number portability the number might not belong to the returned carrier anymore. If no mapping is found an empty string is returned. This function explicitly checks the validity of the number passed in Arguments: numobj -- The PhoneNumber object for which we want to get a carrier name. lang -- A 2-letter lowercase ISO 639-1 language code for the language in which the description should be returned (e.g. "en") script -- A 4-letter titlecase (first letter uppercase, rest lowercase) ISO script code as defined in ISO 15924, separated by an underscore (e.g. "Hant") region -- A 2-letter uppercase ISO 3166-1 country code (e.g. "GB") Returns a carrier name in the given language code, for the given phone number, or an empty string if no description is available.` name_for_valid_number(numobj, lang, script=None, region=None) `Returns a carrier name for the given PhoneNumber object, in the language provided. The carrier name is the one the number was originally allocated to, however if the country supports mobile number portability the number might not belong to the returned carrier anymore. If no mapping is found an empty string is returned. This method assumes the validity of the number passed in has already been checked, and that the number is suitable for carrier lookup. We consider mobile and pager numbers possible candidates for carrier lookup. Arguments: numobj -- The PhoneNumber object for which we want to get a carrier name. lang -- A 2-letter lowercase ISO 639-1 language code for the language in which the description should be returned (e.g. "en") script -- A 4-letter titlecase (first letter uppercase, rest lowercase) ISO script code as defined in ISO 15924, separated by an underscore (e.g. "Hant") region -- A 2-letter uppercase ISO 3166-1 country code (e.g. "GB") Returns a carrier name in the given language code, for the given phone number, or an empty string if no description is available.` safe_display_name(numobj, lang, script=None, region=None) `Gets the name of the carrier for the given PhoneNumber object only when it is 'safe' to display to users. A carrier name is onsidered safe if the number is valid and for a region that doesn't support mobile number portability (http://en.wikipedia.org/wiki/Mobile_number_portability). This function explicitly checks the validity of the number passed in Arguments: numobj -- The PhoneNumber object for which we want to get a carrier name. lang -- A 2-letter lowercase ISO 639-1 language code for the language in which the description should be returned (e.g. "en") script -- A 4-letter titlecase (first letter uppercase, rest lowercase) ISO script code as defined in ISO 15924, separated by an underscore (e.g. "Hant") region -- A 2-letter uppercase ISO 3166-1 country code (e.g. "GB") Returns a carrier name that is safe to display to users, or the empty string.`

Data
`` |  | __all__ = ['name_for_valid_number', 'name_for_number', 'safe_display_name']