MCPcopy
hub / github.com/django/django / phone2numeric

Function phone2numeric

django/utils/text.py:314–344  ·  view source on GitHub ↗

Convert a phone number with letters into its numeric equivalent.

(phone)

Source from the content-addressed store, hash-verified

312
313@keep_lazy_text
314def phone2numeric(phone):
315 """Convert a phone number with letters into its numeric equivalent."""
316 char2number = {
317 "a": "2",
318 "b": "2",
319 "c": "2",
320 "d": "3",
321 "e": "3",
322 "f": "3",
323 "g": "4",
324 "h": "4",
325 "i": "4",
326 "j": "5",
327 "k": "5",
328 "l": "5",
329 "m": "6",
330 "n": "6",
331 "o": "6",
332 "p": "7",
333 "q": "7",
334 "r": "7",
335 "s": "7",
336 "t": "8",
337 "u": "8",
338 "v": "8",
339 "w": "9",
340 "x": "9",
341 "y": "9",
342 "z": "9",
343 }
344 return "".join(char2number.get(c, c) for c in phone.lower())
345
346
347def _get_random_filename(max_random_bytes):

Callers 1

phone2numeric_filterFunction · 0.90

Calls 2

joinMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected