|
126 | 126 | from .phonenumbermatcher import PhoneNumberMatch, PhoneNumberMatcher, Leniency |
127 | 127 |
|
128 | 128 |
|
129 | | -# The geodata occupies a lot of space, so only perform the import on first use |
130 | | -# of geocoder functionality. |
131 | | -def country_name_for_number(*args, **kwargs): |
132 | | - """Return the given PhoneNumber object's country name in the given language. |
133 | | -
|
134 | | - Arguments: |
135 | | - numobj -- The PhoneNumber object for which we want to get a text description. |
136 | | - lang -- A 2-letter lowercase ISO 639-1 language code for the language in |
137 | | - which the description should be returned (e.g. "en") |
138 | | - script -- A 4-letter titlecase (first letter uppercase, rest lowercase) |
139 | | - ISO script code as defined in ISO 15924, separated by an |
140 | | - underscore (e.g. "Hant") |
141 | | - region -- A 2-letter uppercase ISO 3166-1 country code (e.g. "GB") |
142 | | -
|
143 | | - The script and region parameters are currently ignored. |
144 | | -
|
145 | | - Returns a text description in the given language code, for the given phone |
146 | | - number's region, or an empty string if no description is available.""" |
147 | | - from .geocoder import country_name_for_number as real_fn |
148 | | - return real_fn(*args, **kwargs) |
149 | | - |
150 | | - |
151 | | -def description_for_number(*args, **kwargs): |
152 | | - """Return a text description of a PhoneNumber object for the given language. |
153 | | -
|
154 | | - The description might consist of the name of the country where the phone |
155 | | - number is from and/or the name of the geographical area the phone number |
156 | | - is from. This function explicitly checks the validity of the number passed in |
157 | | -
|
158 | | - Arguments: |
159 | | - numobj -- The PhoneNumber object for which we want to get a text description. |
160 | | - lang -- A 2-letter lowercase ISO 639-1 language code for the language in |
161 | | - which the description should be returned (e.g. "en") |
162 | | - script -- A 4-letter titlecase (first letter uppercase, rest lowercase) |
163 | | - ISO script code as defined in ISO 15924, separated by an |
164 | | - underscore (e.g. "Hant") |
165 | | - region -- A 2-letter uppercase ISO 3166-1 country code (e.g. "GB") |
166 | | -
|
167 | | - Returns a text description in the given language code, for the given phone |
168 | | - number, or an empty string if no description is available.""" |
169 | | - from .geocoder import description_for_number as real_fn |
170 | | - return real_fn(*args, **kwargs) |
171 | | - |
172 | | - |
173 | | -def description_for_valid_number(*args, **kwargs): |
174 | | - """Return a text description of a PhoneNumber object, in the language |
175 | | - provided. |
176 | | -
|
177 | | - The description might consist of the name of the country where the phone |
178 | | - number is from and/or the name of the geographical area the phone number |
179 | | - is from if more detailed information is available. |
180 | | -
|
181 | | - If the phone number is from the same region as the user, only a |
182 | | - lower-level description will be returned, if one exists. Otherwise, the |
183 | | - phone number's region will be returned, with optionally some more detailed |
184 | | - information. |
185 | | -
|
186 | | - For example, for a user from the region "US" (United States), we would |
187 | | - show "Mountain View, CA" for a particular number, omitting the United |
188 | | - States from the description. For a user from the United Kingdom (region |
189 | | - "GB"), for the same number we may show "Mountain View, CA, United States" |
190 | | - or even just "United States". |
191 | | -
|
192 | | - This function assumes the validity of the number passed in has already |
193 | | - been checked, and that the number is suitable for geocoding. We consider |
194 | | - fixed-line and mobile numbers possible candidates for geocoding. |
195 | | -
|
196 | | - Arguments: |
197 | | - numobj -- A valid PhoneNumber object for which we want to get a text |
198 | | - description. |
199 | | - lang -- A 2-letter lowercase ISO 639-1 language code for the language in |
200 | | - which the description should be returned (e.g. "en") |
201 | | - script -- A 4-letter titlecase (first letter uppercase, rest lowercase) |
202 | | - ISO script code as defined in ISO 15924, separated by an |
203 | | - underscore (e.g. "Hant") |
204 | | - region -- The region code for a given user. This region will be omitted |
205 | | - from the description if the phone number comes from this |
206 | | - region. It is a two-letter uppercase ISO country code as |
207 | | - defined by ISO 3166-1. |
208 | | -
|
209 | | - Returns a text description in the given language code, for the given phone |
210 | | - number, or an empty string if no description is available.""" |
211 | | - from .geocoder import description_for_valid_number as real_fn |
212 | | - return real_fn(*args, **kwargs) |
213 | | - |
214 | | - |
215 | 129 | # Version number is taken from the upstream libphonenumber version |
216 | 130 | # together with an indication of the version of the Python-specific code. |
217 | 131 | __version__ = "5.8b1" |
@@ -272,9 +186,6 @@ def description_for_valid_number(*args, **kwargs): |
272 | 186 | 'is_carrier_specific', |
273 | 187 | # end of items from shortnumberinfo.py |
274 | 188 | 'PhoneNumberMatch', 'PhoneNumberMatcher', 'Leniency', |
275 | | - 'country_name_for_number', |
276 | | - 'description_for_number', |
277 | | - 'description_for_valid_number', |
278 | 189 | ] |
279 | 190 |
|
280 | 191 | if __name__ == '__main__': # pragma no cover |
|
0 commit comments