|
27 | 27 | importos |
28 | 28 | importre |
29 | 29 | importsys |
| 30 | +importurllib.request |
30 | 31 | fromcollectionsimportdefaultdict |
31 | 32 | fromitertoolsimportbatched |
32 | 33 |
|
| 34 | +UNICODE_VERSION="15.1.0" |
| 35 | +"""The version of the Unicode data files to download.""" |
| 36 | + |
33 | 37 | NUM_CODEPOINTS=0x110000 |
34 | 38 | """An upper bound for which `range(0, NUM_CODEPOINTS)` contains Unicode's codespace.""" |
35 | 39 |
|
@@ -70,11 +74,13 @@ class OffsetType(enum.IntEnum): |
70 | 74 |
|
71 | 75 | deffetch_open(filename:str): |
72 | 76 | """Opens `filename` and return its corresponding file object. If `filename` isn't on disk, |
73 | | - fetches it from `https://www.unicode.org/Public/UNIDATA/`. Exits with code 1 on failure. |
| 77 | + fetches it from `https://www.unicode.org/Public/`. Exits with code 1 on failure. |
74 | 78 | """ |
75 | 79 | basename=os.path.basename(filename) |
76 | 80 | ifnotos.path.exists(basename): |
77 | | -os.system(f"curl -O https://www.unicode.org/Public/UNIDATA/{filename}") |
| 81 | +urllib.request.urlretrieve( |
| 82 | +f"https://www.unicode.org/Public/{UNICODE_VERSION}/ucd/{filename}",basename |
| 83 | + ) |
78 | 84 | try: |
79 | 85 | returnopen(basename,encoding="utf-8") |
80 | 86 | exceptOSError: |
|