MCPcopy Index your code
hub / github.com/python/cpython / open_data

Function open_data

Tools/unicode/makeunicodedata.py:906–921  ·  view source on GitHub ↗
(template, version)

Source from the content-addressed store, hash-verified

904DATA_DIR = os.path.join('Tools', 'unicode', 'data')
905
906def open_data(template, version):
907 local = os.path.join(DATA_DIR, template % ('-'+version,))
908 if not os.path.exists(local):
909 import urllib.request
910 if version == '3.2.0':
911 # irregular url structure
912 url = ('https://www.unicode.org/Public/3.2-Update/'+template) % ('-'+version,)
913 else:
914 url = ('https://www.unicode.org/Public/%s/ucd/'+template) % (version, '')
915 os.makedirs(os.path.dirname(local), exist_ok=True)
916 urllib.request.urlretrieve(url, filename=local)
917 if local.endswith('.txt'):
918 return open(local, encoding='utf-8')
919 else:
920 # Unihan.zip
921 return open(local, 'rb')
922
923
924def expand_range(char_range: str) -> Iterator[int]:

Callers 2

recordsMethod · 0.85
__init__Method · 0.85

Calls 6

urlretrieveMethod · 0.80
openFunction · 0.50
joinMethod · 0.45
existsMethod · 0.45
dirnameMethod · 0.45
endswithMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…