Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3e4498d

Browse files
gnpricebenjaminp
authored andcommitted
bpo-37760: Avoid cluttering work tree with downloaded Unicode files. (GH-15128)
1 parent 68e495d commit 3e4498d

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ PCbuild/arm32/
7474
PCbuild/arm64/
7575
PCbuild/obj/
7676
PCbuild/win32/
77+
Tools/unicode/data/
7778
.purify
7879
__pycache__
7980
autom4te.cache

Tools/unicode/makeunicodedata.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -887,15 +887,18 @@ class Difference(Exception):pass
887887
normalization_changes))
888888

889889

890+
DATA_DIR = os.path.join('Tools', 'unicode', 'data')
891+
890892
def open_data(template, version):
891-
local = template % ('-'+version,)
893+
local = os.path.join(DATA_DIR, template % ('-'+version,))
892894
if not os.path.exists(local):
893895
import urllib.request
894896
if version == '3.2.0':
895897
# irregular url structure
896-
url = 'http://www.unicode.org/Public/3.2-Update/' + local
898+
url = ('http://www.unicode.org/Public/3.2-Update/'+template) % ('-'+version,)
897899
else:
898900
url = ('http://www.unicode.org/Public/%s/ucd/'+template) % (version, '')
901+
os.makedirs(DATA_DIR, exist_ok=True)
899902
urllib.request.urlretrieve(url, filename=local)
900903
if local.endswith('.txt'):
901904
return open(local, encoding='utf-8')

0 commit comments

Comments
 (0)