From a025df0943f22af529d967314138f3ef3a30e076 Mon Sep 17 00:00:00 2001 From: guidotheelen Date: Fri, 7 Aug 2020 14:42:11 +0200 Subject: [PATCH 1/5] fix double dir name bug --- check_emoji_sequences.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/check_emoji_sequences.py b/check_emoji_sequences.py index 3405f2e62..b664203a0 100755 --- a/check_emoji_sequences.py +++ b/check_emoji_sequences.py @@ -365,7 +365,7 @@ def collect_name_to_dirpath(directory, prefix, suffix, exclude=None): dirs[:] = [d for d in dirs if d not in exclude] if directory != '.': - dirname = path.join(directory, dirname) + dirname = directory for f in files: if not f.endswith(suffix): continue From 4f41aa7c550a82687f0cda941e1d409334665059 Mon Sep 17 00:00:00 2001 From: guidotheelen Date: Fri, 7 Aug 2020 14:43:53 +0200 Subject: [PATCH 2/5] use names from makefile as input --- Makefile | 2 +- check_emoji_sequences.py | 25 ++++++++++++++++++------- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index ca6b7e34b..3e761036e 100644 --- a/Makefile +++ b/Makefile @@ -219,7 +219,7 @@ check_sequence: ifdef BYPASS_SEQUENCE_CHECK @echo Bypassing the emoji sequence checks else - $(PYTHON) $(SEQUENCE_CHECK_PY) -d $(EMOJI_SRC_DIR) -c + @$(PYTHON) $(SEQUENCE_CHECK_PY) -n $(ALL_NAMES) -c endif clean: diff --git a/check_emoji_sequences.py b/check_emoji_sequences.py index b664203a0..3b77a27a3 100755 --- a/check_emoji_sequences.py +++ b/check_emoji_sequences.py @@ -389,25 +389,36 @@ def collect_name_to_dirpath_with_override(dirs, prefix, suffix, exclude=None): return result -def run_check(dirs, prefix, suffix, exclude, unicode_version, coverage): +def run_check(dirs, names, prefix, suffix, exclude, unicode_version, coverage): msg = '' if unicode_version: msg = ' (%3.1f)' % unicode_version - print(f'Checking files with prefix "{prefix}" and suffix "{suffix}"{msg} in: {dirs}') - name_to_dirpath = collect_name_to_dirpath_with_override( - dirs, prefix=prefix, suffix=suffix, exclude=exclude) + + if (names and dirs): + sys.exit("Please only provide a directory or a list of names") + elif names: + name_to_dirpath = {} + for name in names: + name_to_dirpath[name] = "" + elif dirs: + print(f'Checking files with prefix "{prefix}" and suffix "{suffix}"{msg} in: {dirs}') + name_to_dirpath = collect_name_to_dirpath_with_override(dirs, prefix=prefix, suffix=suffix, exclude=exclude) + print(f'checking {len(name_to_dirpath)} names') seq_to_filepath = create_sequence_to_filepath(name_to_dirpath, prefix, suffix) print(f'checking {len(seq_to_filepath)} sequences') check_sequence_to_filepath(seq_to_filepath, unicode_version, coverage) - print('done running checks') + print('Done running checks') def main(): parser = argparse.ArgumentParser() parser.add_argument( '-d', '--dirs', help='directory roots containing emoji images', - metavar='dir', nargs='+', required=True) + metavar='dir', nargs='+') + parser.add_argument( + '-n', '--names', help='list with expected emoji', + metavar='names', nargs='+') parser.add_argument( '-e', '--exclude', help='names of source subdirs to exclude', metavar='dir', nargs='+') @@ -425,7 +436,7 @@ def main(): metavar='version', type=float) args = parser.parse_args() run_check( - args.dirs, args.prefix, args.suffix, args.exclude, args.unicode_version, + args.dirs, args.names, args.prefix, args.suffix, args.exclude, args.unicode_version, args.coverage) From c679409f9bd14537cdf81c96774f028d6d9efdba Mon Sep 17 00:00:00 2001 From: guidotheelen Date: Mon, 10 Aug 2020 14:25:13 +0200 Subject: [PATCH 3/5] use second argument for emoji_builder --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 3e761036e..ff684625b 100644 --- a/Makefile +++ b/Makefile @@ -209,7 +209,7 @@ $(COMPRESSED_DIR)/%.png: $(QUANTIZED_DIR)/%.png | check_tools $(COMPRESSED_DIR) $(EMOJI).ttf: check_sequence $(EMOJI).tmpl.ttf $(EMOJI_BUILDER) $(PUA_ADDER) \ $(ALL_COMPRESSED_FILES) | check_tools - @$(PYTHON) $(EMOJI_BUILDER) $(SMALL_METRICS) -V $< "$@" "$(COMPRESSED_DIR)/emoji_u" + @$(PYTHON) $(EMOJI_BUILDER) $(SMALL_METRICS) -V $(word 2,$^) "$@" "$(COMPRESSED_DIR)/emoji_u" @$(PYTHON) $(PUA_ADDER) "$@" "$@-with-pua" @$(VS_ADDER) -vs 2640 2642 2695 --dstdir '.' -o "$@-with-pua-varsel" "$@-with-pua" @mv "$@-with-pua-varsel" "$@" From 887e4d1b073a4286b6e666b84373100f8e811e31 Mon Sep 17 00:00:00 2001 From: guidotheelen Date: Wed, 12 Aug 2020 08:40:50 +0200 Subject: [PATCH 4/5] fail build when non-emoji cp is found --- check_emoji_sequences.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/check_emoji_sequences.py b/check_emoji_sequences.py index 3b77a27a3..1615da5af 100755 --- a/check_emoji_sequences.py +++ b/check_emoji_sequences.py @@ -90,6 +90,8 @@ def _check_valid_emoji_cps(sorted_seq_to_filepath, unicode_version): used in forming emoji sequences. This is a 'pre-check' that reports this specific problem.""" + coverage_pass = True + valid_cps = set(unicode_data.get_emoji()) if unicode_version is None or unicode_version >= unicode_data.PROPOSED_EMOJI_AGE: valid_cps |= unicode_data.proposed_emoji_cps() @@ -116,7 +118,11 @@ def _check_valid_emoji_cps(sorted_seq_to_filepath, unicode_version): for cp in sorted(not_emoji): fps = not_emoji[cp] print( - f'check valid emoji cps: {cp} (in {len(fps)} sequences)', file=sys.stderr) + f'check the following cp: {cp} - {not_emoji.get(cp)[0]} (in {len(fps)} sequences)', file=sys.stderr) + coverage_pass = False + + if not coverage_pass: + exit("Please fix the problems metioned above or run: make BYPASS_SEQUENCE_CHECK='True'") def _check_zwj(sorted_seq_to_filepath): From 65a67374232f96bb18ce900e25b4588a82368225 Mon Sep 17 00:00:00 2001 From: guidotheelen Date: Tue, 18 Aug 2020 15:25:50 +0200 Subject: [PATCH 5/5] fix indentation --- check_emoji_sequences.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/check_emoji_sequences.py b/check_emoji_sequences.py index 1615da5af..d1f60097e 100755 --- a/check_emoji_sequences.py +++ b/check_emoji_sequences.py @@ -399,7 +399,7 @@ def run_check(dirs, names, prefix, suffix, exclude, unicode_version, coverage): msg = '' if unicode_version: msg = ' (%3.1f)' % unicode_version - + if (names and dirs): sys.exit("Please only provide a directory or a list of names") elif names: @@ -407,8 +407,8 @@ def run_check(dirs, names, prefix, suffix, exclude, unicode_version, coverage): for name in names: name_to_dirpath[name] = "" elif dirs: - print(f'Checking files with prefix "{prefix}" and suffix "{suffix}"{msg} in: {dirs}') - name_to_dirpath = collect_name_to_dirpath_with_override(dirs, prefix=prefix, suffix=suffix, exclude=exclude) + print(f'Checking files with prefix "{prefix}" and suffix "{suffix}"{msg} in: {dirs}') + name_to_dirpath = collect_name_to_dirpath_with_override(dirs, prefix=prefix, suffix=suffix, exclude=exclude) print(f'checking {len(name_to_dirpath)} names') seq_to_filepath = create_sequence_to_filepath(name_to_dirpath, prefix, suffix)