forked from daviddrysdale/python-phonenumbers
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathphonenumbers.carrier.html
More file actions
98 lines (95 loc) · 8.71 KB
/
Copy pathphonenumbers.carrier.html
File metadata and controls
98 lines (95 loc) · 8.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Python: module phonenumbers.carrier</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head><body bgcolor="#f0f0f8">
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
<tr bgcolor="#7799ee">
<td valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"> <br><big><big><strong><a href="phonenumbers.html"><font color="#ffffff">phonenumbers</font></a>.carrier</strong></big></big></font></td
><td align=right valign=bottom
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="https://github.com/daviddrysdale/python-phonenumbers/blob/dev/python/phonenumbers/carrier.py">phonenumbers/carrier.py</a></font></td></tr></table>
<p><tt>Phone number to carrier mapping functionality<br>
<br>
>>> import phonenumbers<br>
>>> from phonenumbers.carrier import name_for_number<br>
>>> ro_number = phonenumbers.parse("+40721234567", "RO")<br>
>>> str(<a href="#-name_for_number">name_for_number</a>(ro_number, "en"))<br>
'Vodafone'<br>
>>> str(<a href="#-name_for_number">name_for_number</a>(ro_number, "fr")) # fall back to English<br>
'Vodafone'</tt></p>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#eeaa77">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr>
<tr><td bgcolor="#eeaa77"><tt> </tt></td><td> </td>
<td width="100%"><dl><dt><a name="-name_for_number"><strong>name_for_number</strong></a>(numobj, lang, script=None, region=None)</dt><dd><tt>Returns a carrier name for the given PhoneNumber object, in the<br>
language provided.<br>
<br>
The carrier name is the one the number was originally allocated to,<br>
however if the country supports mobile number portability the number might<br>
not belong to the returned carrier anymore. If no mapping is found an<br>
empty string is returned.<br>
<br>
This function explicitly checks the validity of the number passed in<br>
<br>
Arguments:<br>
numobj -- The PhoneNumber object for which we want to get a carrier name.<br>
lang -- A 2-letter lowercase ISO 639-1 language code for the language in<br>
which the description should be returned (e.g. "en")<br>
script -- A 4-letter titlecase (first letter uppercase, rest lowercase)<br>
ISO script code as defined in ISO 15924, separated by an<br>
underscore (e.g. "Hant")<br>
region -- A 2-letter uppercase ISO 3166-1 country code (e.g. "GB")<br>
<br>
Returns a carrier name in the given language code, for the given phone<br>
number, or an empty string if no description is available.</tt></dd></dl>
<dl><dt><a name="-name_for_valid_number"><strong>name_for_valid_number</strong></a>(numobj, lang, script=None, region=None)</dt><dd><tt>Returns a carrier name for the given PhoneNumber object, in the<br>
language provided.<br>
<br>
The carrier name is the one the number was originally allocated to,<br>
however if the country supports mobile number portability the number might<br>
not belong to the returned carrier anymore. If no mapping is found an<br>
empty string is returned.<br>
<br>
This method assumes the validity of the number passed in has already been<br>
checked, and that the number is suitable for carrier lookup. We consider<br>
mobile and pager numbers possible candidates for carrier lookup.<br>
<br>
Arguments:<br>
numobj -- The PhoneNumber object for which we want to get a carrier name.<br>
lang -- A 2-letter lowercase ISO 639-1 language code for the language in<br>
which the description should be returned (e.g. "en")<br>
script -- A 4-letter titlecase (first letter uppercase, rest lowercase)<br>
ISO script code as defined in ISO 15924, separated by an<br>
underscore (e.g. "Hant")<br>
region -- A 2-letter uppercase ISO 3166-1 country code (e.g. "GB")<br>
<br>
Returns a carrier name in the given language code, for the given phone<br>
number, or an empty string if no description is available.</tt></dd></dl>
<dl><dt><a name="-safe_display_name"><strong>safe_display_name</strong></a>(numobj, lang, script=None, region=None)</dt><dd><tt>Gets the name of the carrier for the given PhoneNumber object only when<br>
it is 'safe' to display to users. A carrier name is onsidered safe if the<br>
number is valid and for a region that doesn't support mobile number<br>
portability (<a href="http://en.wikipedia.org/wiki/Mobile_number_portability">http://en.wikipedia.org/wiki/Mobile_number_portability</a>).<br>
<br>
<br>
This function explicitly checks the validity of the number passed in<br>
<br>
Arguments:<br>
numobj -- The PhoneNumber object for which we want to get a carrier name.<br>
lang -- A 2-letter lowercase ISO 639-1 language code for the language in<br>
which the description should be returned (e.g. "en")<br>
script -- A 4-letter titlecase (first letter uppercase, rest lowercase)<br>
ISO script code as defined in ISO 15924, separated by an<br>
underscore (e.g. "Hant")<br>
region -- A 2-letter uppercase ISO 3166-1 country code (e.g. "GB")<br>
<br>
Returns a carrier name that is safe to display to users, or the empty string.</tt></dd></dl>
</td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#55aa55">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr>
<tr><td bgcolor="#55aa55"><tt> </tt></td><td> </td>
<td width="100%"><strong>__all__</strong> = ['name_for_valid_number', 'name_for_number', 'safe_display_name']</td></tr></table>
</body></html>