MCPcopy
hub / github.com/daviddrysdale/python-phonenumbers / get

Method get

python/phonenumbers/unicode_util.py:382–398  ·  view source on GitHub ↗

Return the Unicode block of the given Unicode character

(cls, uni_char)

Source from the content-addressed store, hash-verified

380
381 @classmethod
382 def get(cls, uni_char):
383 """Return the Unicode block of the given Unicode character"""
384 uni_char = unicod(uni_char) # Force to Unicode
385 code_point = ord(uni_char)
386 if Block._RANGE_KEYS is None:
387 Block._RANGE_KEYS = sorted(Block._RANGES.keys())
388 idx = bisect.bisect_left(Block._RANGE_KEYS, code_point)
389 if (idx > 0 and
390 code_point >= Block._RANGES[Block._RANGE_KEYS[idx - 1]].start and
391 code_point <= Block._RANGES[Block._RANGE_KEYS[idx - 1]].end):
392 return Block._RANGES[Block._RANGE_KEYS[idx - 1]]
393 elif (idx < len(Block._RANGES) and
394 code_point >= Block._RANGES[Block._RANGE_KEYS[idx]].start and
395 code_point <= Block._RANGES[Block._RANGE_KEYS[idx]].end):
396 return Block._RANGES[Block._RANGE_KEYS[idx]]
397 else:
398 return Block.UNKNOWN
399
400
401def digit(uni_char, default_value=None):

Callers 15

__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45
mainMethod · 0.45
_is_latin_letterMethod · 0.45
_find_langFunction · 0.45
country_mobile_tokenFunction · 0.45
_normalize_helperFunction · 0.45
region_code_for_numberFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected