Commit 3e4498d3 authored by Greg Price's avatar Greg Price Committed by Benjamin Peterson

bpo-37760: Avoid cluttering work tree with downloaded Unicode files. (GH-15128)

parent 68e495df
...@@ -74,6 +74,7 @@ PCbuild/arm32/ ...@@ -74,6 +74,7 @@ PCbuild/arm32/
PCbuild/arm64/ PCbuild/arm64/
PCbuild/obj/ PCbuild/obj/
PCbuild/win32/ PCbuild/win32/
Tools/unicode/data/
.purify .purify
__pycache__ __pycache__
autom4te.cache autom4te.cache
......
...@@ -887,15 +887,18 @@ def merge_old_version(version, new, old): ...@@ -887,15 +887,18 @@ def merge_old_version(version, new, old):
normalization_changes)) normalization_changes))
DATA_DIR = os.path.join('Tools', 'unicode', 'data')
def open_data(template, version): def open_data(template, version):
local = template % ('-'+version,) local = os.path.join(DATA_DIR, template % ('-'+version,))
if not os.path.exists(local): if not os.path.exists(local):
import urllib.request import urllib.request
if version == '3.2.0': if version == '3.2.0':
# irregular url structure # irregular url structure
url = 'http://www.unicode.org/Public/3.2-Update/' + local url = ('http://www.unicode.org/Public/3.2-Update/'+template) % ('-'+version,)
else: else:
url = ('http://www.unicode.org/Public/%s/ucd/'+template) % (version, '') url = ('http://www.unicode.org/Public/%s/ucd/'+template) % (version, '')
os.makedirs(DATA_DIR, exist_ok=True)
urllib.request.urlretrieve(url, filename=local) urllib.request.urlretrieve(url, filename=local)
if local.endswith('.txt'): if local.endswith('.txt'):
return open(local, encoding='utf-8') return open(local, encoding='utf-8')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment