diff --git a/src/gen-arabic-table.py b/src/gen-arabic-table.py index f1d715c86..f910d419e 100755 --- a/src/gen-arabic-table.py +++ b/src/gen-arabic-table.py @@ -1,15 +1,17 @@ #!/usr/bin/env python3 -import io, os.path, sys - -if len (sys.argv) != 4: - print ("""usage: ./gen-arabic-table.py ArabicShaping.txt UnicodeData.txt Blocks.txt +"""usage: ./gen-arabic-table.py ArabicShaping.txt UnicodeData.txt Blocks.txt Input files: * https://unicode.org/Public/UCD/latest/ucd/ArabicShaping.txt * https://unicode.org/Public/UCD/latest/ucd/UnicodeData.txt * https://unicode.org/Public/UCD/latest/ucd/Blocks.txt -""", file=sys.stderr) +""" + +import io, os.path, sys + +if len (sys.argv) != 4: + print (__doc__, file=sys.stderr) sys.exit (1) files = [io.open (x, encoding='utf-8') for x in sys.argv[1:]] @@ -126,7 +128,7 @@ def print_joining_table(f): print ("}; /* Table items: %d; occupancy: %d%% */" % (offset, occupancy)) print () - page_bits = 12; + page_bits = 12 print () print ("static unsigned int") print ("joining_type (hb_codepoint_t u)") diff --git a/src/gen-def.py b/src/gen-def.py index 37f54bc22..21e49c4f1 100755 --- a/src/gen-def.py +++ b/src/gen-def.py @@ -1,9 +1,11 @@ #!/usr/bin/env python3 +"usage: gen-def.py harfbuzz.def hb.h [hb-blob.h hb-buffer.h ...]" + import io, os, re, sys if len (sys.argv) < 3: - sys.exit("usage: gen-def.py harfbuzz.def hb.h [hb-blob.h hb-buffer.h ...]") + sys.exit(__doc__) output_file = sys.argv[1] header_paths = sys.argv[2:] diff --git a/src/gen-emoji-table.py b/src/gen-emoji-table.py index 615be9a00..6d5ca6e34 100755 --- a/src/gen-emoji-table.py +++ b/src/gen-emoji-table.py @@ -1,15 +1,18 @@ #!/usr/bin/env python3 +"""usage: ./gen-emoji-table.py emoji-data.txt + +Input file: +* https://www.unicode.org/Public/UCD/latest/ucd/emoji/emoji-data.txt +""" + import sys import os.path from collections import OrderedDict import packTab if len (sys.argv) != 2: - print("""usage: ./gen-emoji-table.py emoji-data.txt - -Input file: -* https://www.unicode.org/Public/UCD/latest/ucd/emoji/emoji-data.txt""", file=sys.stderr) + print(__doc__, file=sys.stderr) sys.exit (1) f = open(sys.argv[1]) diff --git a/src/gen-harfbuzzcc.py b/src/gen-harfbuzzcc.py index 706a296b5..c0ac7d71b 100755 --- a/src/gen-harfbuzzcc.py +++ b/src/gen-harfbuzzcc.py @@ -1,9 +1,11 @@ #!/usr/bin/env python3 +"usage: gen-harfbuzzcc.py harfbuzz.cc hb-blob.cc hb-buffer.cc ..." + import io, os, re, sys if len (sys.argv) < 3: - sys.exit("usage: gen-harfbuzzcc.py harfbuzz.def hb-blob.cc hb-buffer.cc ...") + sys.exit(__doc__) output_file = sys.argv[1] source_paths = sys.argv[2:] diff --git a/src/gen-hb-version.py b/src/gen-hb-version.py index e29642425..beb8e5a79 100755 --- a/src/gen-hb-version.py +++ b/src/gen-hb-version.py @@ -1,9 +1,11 @@ #!/usr/bin/env python3 +"usage: gen-hb-version.py 1.0.0 hb-version.h.in hb-version.h" + import io, os, re, sys if len (sys.argv) < 4: - sys.exit("usage: gen-hb-version.py 1.0.0 hb-version.h.in hb-version.h") + sys.exit(__doc__) version = sys.argv[1] major, minor, micro = version.split (".") diff --git a/src/gen-indic-table.py b/src/gen-indic-table.py index e1c3c9ecf..edc898b31 100755 --- a/src/gen-indic-table.py +++ b/src/gen-indic-table.py @@ -1,14 +1,17 @@ #!/usr/bin/env python3 -import io, sys - -if len (sys.argv) != 4: - print ("""usage: ./gen-indic-table.py IndicSyllabicCategory.txt IndicPositionalCategory.txt Blocks.txt +"""usage: ./gen-indic-table.py IndicSyllabicCategory.txt IndicPositionalCategory.txt Blocks.txt Input files: * https://unicode.org/Public/UCD/latest/ucd/IndicSyllabicCategory.txt * https://unicode.org/Public/UCD/latest/ucd/IndicPositionalCategory.txt -* https://unicode.org/Public/UCD/latest/ucd/Blocks.txt""", file=sys.stderr) +* https://unicode.org/Public/UCD/latest/ucd/Blocks.txt +""" + +import io, sys + +if len (sys.argv) != 4: + print (__doc__, file=sys.stderr) sys.exit (1) ALLOWED_SINGLES = [0x00A0, 0x25CC] diff --git a/src/gen-os2-unicode-ranges.py b/src/gen-os2-unicode-ranges.py index 4d433c50b..a17219d56 100755 --- a/src/gen-os2-unicode-ranges.py +++ b/src/gen-os2-unicode-ranges.py @@ -1,8 +1,9 @@ #!/usr/bin/env python3 -# Generates the code for a sorted unicode range array as used in hb-ot-os2-unicode-ranges.hh -# Input is a tab seperated list of unicode ranges from the otspec -# (https://docs.microsoft.com/en-us/typography/opentype/spec/os2#ur). +"""Generates the code for a sorted unicode range array as used in hb-ot-os2-unicode-ranges.hh +Input is a tab seperated list of unicode ranges from the otspec +(https://docs.microsoft.com/en-us/typography/opentype/spec/os2#ur). +""" import io import re @@ -17,7 +18,7 @@ input_file = args[0] with io.open(input_file, mode="r", encoding="utf-8") as f: - all_ranges = []; + all_ranges = [] current_bit = 0 while True: line = f.readline().strip() diff --git a/src/gen-tag-table.py b/src/gen-tag-table.py index 3dceccaa1..41baff3f3 100755 --- a/src/gen-tag-table.py +++ b/src/gen-tag-table.py @@ -16,6 +16,12 @@ back to BCP 47 tags. Ambiguous OpenType tags (those that correspond to multiple BCP 47 tags) are listed here, except when the alphabetically first BCP 47 tag happens to be the chosen disambiguated tag. In that case, the fallback behavior will choose the right tag anyway. + +usage: ./gen-tag-table.py languagetags language-subtag-registry + +Input files: +* https://docs.microsoft.com/en-us/typography/opentype/spec/languagetags +* https://www.iana.org/assignments/language-subtag-registry/language-subtag-registry """ import collections @@ -30,11 +36,7 @@ import sys import unicodedata if len (sys.argv) != 3: - print ('''usage: ./gen-tag-table.py languagetags language-subtag-registry - -Input files: -* https://docs.microsoft.com/en-us/typography/opentype/spec/languagetags -* https://www.iana.org/assignments/language-subtag-registry/language-subtag-registry''', file=sys.stderr) + print (__doc__, file=sys.stderr) sys.exit (1) from html import unescape diff --git a/src/gen-ucd-table.py b/src/gen-ucd-table.py index 30ab08a7a..02c7ebd16 100755 --- a/src/gen-ucd-table.py +++ b/src/gen-ucd-table.py @@ -1,14 +1,17 @@ #!/usr/bin/env python3 +"""usage: ./gen-ucd-table ucd.nounihan.grouped.xml [/path/to/hb-common.h] + +Input file: +* https://unicode.org/Public/UCD/latest/ucdxml/ucd.nounihan.grouped.zip +""" + import io, os.path, sys, re import logging logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.INFO) if len (sys.argv) not in (2, 3): - print("""usage: ./gen-ucd-table ucd.nounihan.grouped.xml [/path/to/hb-common.h] - -Input file: -* https://unicode.org/Public/UCD/latest/ucdxml/ucd.nounihan.grouped.zip""", file=sys.stderr) + print(__doc__, file=sys.stderr) sys.exit(1) # https://github.com/harfbuzz/packtab diff --git a/src/gen-use-table.py b/src/gen-use-table.py index f1194edf3..26eb0a521 100755 --- a/src/gen-use-table.py +++ b/src/gen-use-table.py @@ -1,17 +1,20 @@ #!/usr/bin/env python3 -# flake8: noqa +# flake8: noqa: F821 -import io -import sys - -if len (sys.argv) != 5: - print ("""usage: ./gen-use-table.py IndicSyllabicCategory.txt IndicPositionalCategory.txt UnicodeData.txt Blocks.txt +"""usage: ./gen-use-table.py IndicSyllabicCategory.txt IndicPositionalCategory.txt UnicodeData.txt Blocks.txt Input file: * https://unicode.org/Public/UCD/latest/ucd/IndicSyllabicCategory.txt * https://unicode.org/Public/UCD/latest/ucd/IndicPositionalCategory.txt * https://unicode.org/Public/UCD/latest/ucd/UnicodeData.txt -* https://unicode.org/Public/UCD/latest/ucd/Blocks.txt""", file=sys.stderr) +* https://unicode.org/Public/UCD/latest/ucd/Blocks.txt +""" + +import io +import sys + +if len (sys.argv) != 5: + print (__doc__, file=sys.stderr) sys.exit (1) BLACKLISTED_BLOCKS = ["Thai", "Lao"] diff --git a/src/gen-vowel-constraints.py b/src/gen-vowel-constraints.py index 6b805636c..e758ea00c 100755 --- a/src/gen-vowel-constraints.py +++ b/src/gen-vowel-constraints.py @@ -7,6 +7,10 @@ circles into sequences prohibited by the USE script development spec. This function should be used as the ``preprocess_text`` of an ``hb_ot_complex_shaper_t``. +usage: ./gen-vowel-constraints.py ms-use/IndicShapingInvalidCluster.txt Scripts.txt + +Input file: +* https://unicode.org/Public/UCD/latest/ucd/Scripts.txt """ import collections @@ -19,10 +23,7 @@ import io import sys if len (sys.argv) != 3: - print ("""usage: ./gen-vowel-constraints.py ms-use/IndicShapingInvalidCluster.txt Scripts.txt - -Input file: -* https://unicode.org/Public/UCD/latest/ucd/Scripts.txt""", file=sys.stderr) + print (__doc__, file=sys.stderr) sys.exit (1) with io.open (sys.argv[2], encoding='utf-8') as f: