forked from daviddrysdale/python-phonenumbers
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathphonenumbers.shortnumberinfo.html
More file actions
229 lines (220 loc) · 18 KB
/
Copy pathphonenumbers.shortnumberinfo.html
File metadata and controls
229 lines (220 loc) · 18 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Python: module phonenumbers.shortnumberinfo</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>.shortnumberinfo</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/shortnumberinfo.py">phonenumbers/shortnumberinfo.py</a></font></td></tr></table>
<p><tt>Methods for getting information about short phone numbers,<br>
such as short codes and emergency numbers.<br>
<br>
Note most commercial short numbers are not handled here, but by phonenumberutil.py</tt></p>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ee77aa">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
<tr><td bgcolor="#ee77aa"><tt> </tt></td><td> </td>
<td width="100%"><dl>
<dt><font face="helvetica, arial"><a href="builtins.html#object">builtins.object</a>
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="phonenumbers.shortnumberinfo.html#ShortNumberCost">ShortNumberCost</a>
</font></dt></dl>
</dd>
</dl>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="ShortNumberCost">class <strong>ShortNumberCost</strong></a>(<a href="builtins.html#object">builtins.object</a>)</font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
<td colspan=2><tt>Cost categories of short numbers.<br> </tt></td></tr>
<tr><td> </td>
<td width="100%">Data descriptors defined here:<br>
<dl><dt><strong>__dict__</strong></dt>
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
</dl>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>list of weak references to the object (if defined)</tt></dd>
</dl>
<hr>
Data and other attributes defined here:<br>
<dl><dt><strong>PREMIUM_RATE</strong> = 2</dl>
<dl><dt><strong>STANDARD_RATE</strong> = 1</dl>
<dl><dt><strong>TOLL_FREE</strong> = 0</dl>
<dl><dt><strong>UNKNOWN_COST</strong> = 3</dl>
</td></tr></table></td></tr></table><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="-connects_to_emergency_number"><strong>connects_to_emergency_number</strong></a>(number, region_code)</dt><dd><tt>Returns whether the given number, exactly as dialled, might be used to<br>
connect to an emergency service in the given region.<br>
<br>
This function accepts a string, rather than a PhoneNumber, because it<br>
needs to distinguish cases such as "+1 911" and "911", where the former<br>
may not connect to an emergency service in all cases but the latter would.<br>
<br>
This function takes into account cases where the number might contain<br>
formatting, or might have additional digits appended (when it is okay to<br>
do that in the specified region).<br>
<br>
Arguments:<br>
number -- The phone number to test.<br>
region_code -- The region where the phone number is being dialed.<br>
<br>
Returns whether the number might be used to connect to an emergency<br>
service in the given region.</tt></dd></dl>
<dl><dt><a name="-expected_cost"><strong>expected_cost</strong></a>(numobj)</dt><dd><tt>Gets the expected cost category of a short number (however, nothing is<br>
implied about its validity). If the country calling code is unique to a<br>
region, this method behaves exactly the same as<br>
expected_cost_for_region. However, if the country calling code is<br>
shared by multiple regions, then it returns the highest cost in the<br>
sequence PREMIUM_RATE, UNKNOWN_COST, STANDARD_RATE, TOLL_FREE. The reason<br>
for the position of UNKNOWN_COST in this order is that if a number is<br>
UNKNOWN_COST in one region but STANDARD_RATE or TOLL_FREE in another, its<br>
expected cost cannot be estimated as one of the latter since it might be a<br>
PREMIUM_RATE number.<br>
<br>
For example, if a number is STANDARD_RATE in the US, but TOLL_FREE in<br>
Canada, the expected cost returned by this method will be STANDARD_RATE,<br>
since the NANPA countries share the same country calling code.<br>
<br>
Note: If the region from which the number is dialed is known, it is highly preferable to call<br>
expected_cost_for_region instead.<br>
<br>
Arguments:<br>
numobj -- the short number for which we want to know the expected cost category<br>
<br>
Return the highest expected cost category of the short number in the<br>
region(s) with the given country calling code</tt></dd></dl>
<dl><dt><a name="-expected_cost_for_region"><strong>expected_cost_for_region</strong></a>(short_numobj, region_dialing_from)</dt><dd><tt>Gets the expected cost category of a short number when dialled from a<br>
region (however, nothing is implied about its validity). If it is<br>
important that the number is valid, then its validity must first be<br>
checked using is_valid_short_number_for_region. Note that emergency<br>
numbers are always considered toll-free.<br>
<br>
Example usage:<br>
short_number = "110"<br>
region_code = "FR"<br>
if phonenumbers.<a href="#-is_valid_short_number_for_region">is_valid_short_number_for_region</a>(short_number, region_code):<br>
cost = phonenumbers.<a href="#-expected_cost">expected_cost</a>(short_number, region_code) # <a href="#ShortNumberCost">ShortNumberCost</a><br>
# Do something with the cost information here.<br>
<br>
Arguments:<br>
short_numobj -- the short number for which we want to know the expected cost category<br>
as a PhoneNumber <a href="builtins.html#object">object</a>.<br>
region_dialing_from -- the region from which the number is dialed<br>
<br>
Return the expected cost category for that region of the short<br>
number. Returns UNKNOWN_COST if the number does not match a cost<br>
category. Note that an invalid number may match any cost category.</tt></dd></dl>
<dl><dt><a name="-is_carrier_specific"><strong>is_carrier_specific</strong></a>(numobj)</dt><dd><tt>Given a valid short number, determines whether it is carrier-specific<br>
(however, nothing is implied about its validity). Carrier-specific numbers<br>
may connect to a different end-point, or not connect at all, depending<br>
on the user's carrier. If it is important that the number is valid, then<br>
its validity must first be checked using is_valid_short_number or<br>
is_valid_short_number_for_region.<br>
<br>
Arguments:<br>
numobj -- the valid short number to check<br>
<br>
Returns whether the short number is carrier-specific, assuming the input<br>
was a valid short number.</tt></dd></dl>
<dl><dt><a name="-is_carrier_specific_for_region"><strong>is_carrier_specific_for_region</strong></a>(numobj, region_dialing_from)</dt><dd><tt>Given a valid short number, determines whether it is carrier-specific when<br>
dialed from the given region (however, nothing is implied about its<br>
validity). Carrier-specific numbers may connect to a different end-point,<br>
or not connect at all, depending on the user's carrier. If it is important<br>
that the number is valid, then its validity must first be checked using<br>
isValidShortNumber or isValidShortNumberForRegion. Returns false if the<br>
number doesn't match the region provided.<br>
<br>
Arguments:<br>
numobj -- the valid short number to check<br>
region_dialing_from -- the region from which the number is dialed<br>
<br>
Returns whether the short number is carrier-specific, assuming the input<br>
was a valid short number.</tt></dd></dl>
<dl><dt><a name="-is_emergency_number"><strong>is_emergency_number</strong></a>(number, region_code)</dt><dd><tt>Returns true if the given number exactly matches an emergency service<br>
number in the given region.<br>
<br>
This method takes into account cases where the number might contain<br>
formatting, but doesn't allow additional digits to be appended. Note that<br>
<a href="#-is_emergency_number">is_emergency_number</a>(number, region) implies<br>
<a href="#-connects_to_emergency_number">connects_to_emergency_number</a>(number, region).<br>
<br>
Arguments:<br>
number -- The phone number to test.<br>
region_code -- The region where the phone number is being dialed.<br>
<br>
Returns if the number exactly matches an emergency services number in the<br>
given region.</tt></dd></dl>
<dl><dt><a name="-is_possible_short_number"><strong>is_possible_short_number</strong></a>(numobj)</dt><dd><tt>Check whether a short number is a possible number.<br>
<br>
If a country calling code is shared by multiple regions, this returns True<br>
if it's possible in any of them. This provides a more lenient check than<br>
is_valid_short_number.<br>
<br>
Arguments:<br>
numobj -- the short number to check<br>
<br>
Return whether the number is a possible short number.</tt></dd></dl>
<dl><dt><a name="-is_possible_short_number_for_region"><strong>is_possible_short_number_for_region</strong></a>(short_numobj, region_dialing_from)</dt><dd><tt>Check whether a short number is a possible number when dialled from a<br>
region. This provides a more lenient check than<br>
is_valid_short_number_for_region.<br>
<br>
Arguments:<br>
short_numobj -- the short number to check as a PhoneNumber <a href="builtins.html#object">object</a>.<br>
region_dialing_from -- the region from which the number is dialed<br>
<br>
Return whether the number is a possible short number.</tt></dd></dl>
<dl><dt><a name="-is_sms_service_for_region"><strong>is_sms_service_for_region</strong></a>(numobj, region_dialing_from)</dt><dd><tt>Given a valid short number, determines whether it is an SMS service<br>
(however, nothing is implied about its validity). An SMS service is where<br>
the primary or only intended usage is to receive and/or send text messages<br>
(SMSs). This includes MMS as MMS numbers downgrade to SMS if the other<br>
party isn't MMS-capable. If it is important that the number is valid, then<br>
its validity must first be checked using is_valid_short_number or<br>
is_valid_short_number_for_region. Returns False if the number doesn't<br>
match the region provided.<br>
<br>
Arguments:<br>
numobj -- the valid short number to check<br>
region_dialing_from -- the region from which the number is dialed<br>
<br>
Returns whether the short number is an SMS service in the provided region,<br>
assuming the input was a valid short number.</tt></dd></dl>
<dl><dt><a name="-is_valid_short_number"><strong>is_valid_short_number</strong></a>(numobj)</dt><dd><tt>Tests whether a short number matches a valid pattern.<br>
<br>
If a country calling code is shared by multiple regions, this returns True<br>
if it's valid in any of them. Note that this doesn't verify the number is<br>
actually in use, which is impossible to tell by just looking at the number<br>
itself. See is_valid_short_number_for_region for details.<br>
<br>
Arguments:<br>
numobj - the short number for which we want to test the validity<br>
<br>
Return whether the short number matches a valid pattern</tt></dd></dl>
<dl><dt><a name="-is_valid_short_number_for_region"><strong>is_valid_short_number_for_region</strong></a>(short_numobj, region_dialing_from)</dt><dd><tt>Tests whether a short number matches a valid pattern in a region.<br>
<br>
Note that this doesn't verify the number is actually in use, which is<br>
impossible to tell by just looking at the number itself.<br>
<br>
Arguments:<br>
short_numobj -- the short number to check as a PhoneNumber <a href="builtins.html#object">object</a>.<br>
region_dialing_from -- the region from which the number is dialed<br>
<br>
Return whether the short number matches a valid pattern</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>SUPPORTED_SHORT_REGIONS</strong> = ['AC', 'AD', 'AE', 'AF', 'AG', 'AI', 'AL', 'AM', 'AO', 'AR', 'AS', 'AT', 'AU', 'AW', 'AX', 'AZ', 'BA', 'BB', 'BD', 'BE', ...]<br>
<strong>U_EMPTY_STRING</strong> = ''</td></tr></table>
</body></html>