Skip to content

Commit

Permalink
added beginnings of emoji properties
Browse files Browse the repository at this point in the history
  • Loading branch information
iwsfutcmd committed Mar 17, 2020
1 parent 4cef3ff commit e29c246
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions makeunicodedata.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
# 2008-06-11 gb add PRINTABLE_MASK for Atsuo Ishimoto's ascii() patch
# 2011-10-21 ezio add support for name aliases and named sequences
# 2012-01 benjamin add full case mappings
# 2019 iwsfutcmd added support for additional properties
#
# written by Fredrik Lundh ([email protected])
#
Expand All @@ -34,6 +35,7 @@
from functools import partial
from textwrap import dedent
from typing import Iterator, List, Optional, Set, Tuple
from pathlib import Path

SCRIPT = sys.argv[0]
VERSION = "3.5"
Expand Down Expand Up @@ -62,6 +64,7 @@
SCRIPT_EXTENSIONS = "ScriptExtensions%s.txt"
INDIC_POSITIONAL_CATEGORY = "IndicPositionalCategory%s.txt"
INDIC_SYLLABIC_CATEGORY = "IndicSyllabicCategory%s.txt"
EMOJI_DATA = "emoji/emoji-data%s.txt"

# Private Use Areas -- in planes 1, 15, 16
PUA_1 = range(0xE000, 0xF900)
Expand Down Expand Up @@ -1060,16 +1063,16 @@ class Difference(Exception):pass
normalization_changes))

def open_data(template, version):
local = template % ('-'+version,)
if not os.path.exists(local):
local = Path(Path(template % ('-'+version,)).name)
if not local.exists():
import urllib.request
if version == '3.2.0':
# irregular url structure
url = 'http://www.unicode.org/Public/3.2-Update/' + local
url = 'http://www.unicode.org/Public/3.2-Update/' + str(local)
else:
url = ('http://www.unicode.org/Public/%s/ucd/'+template) % (version, '')
urllib.request.urlretrieve(url, filename=local)
if local.endswith('.txt'):
if local.suffix == '.txt':
return open(local, encoding='utf-8')
else:
# Unihan.zip
Expand Down Expand Up @@ -1343,6 +1346,10 @@ def __init__(self, version, cjk_check=True):
if table[i] is not None:
table[i].indic_syllabic = indic_syllabic[i]

for char, (p,) in UcdFile(EMOJI_DATA, version).expanded():
if table[char]:
table[char].binary_properties.add(p)

with open_data(UNIHAN, version) as file:
zip = zipfile.ZipFile(file)
if version == '3.2.0':
Expand Down

0 comments on commit e29c246

Please sign in to comment.