mirror of
https://github.com/depp/syncfiles.git
synced 2024-11-22 03:30:57 +00:00
Add script and region constants
These are extracted from the Universal Interfaces Script.h file.
This commit is contained in:
parent
8713cb96aa
commit
7bc44f4a5a
5
scripts/README.md
Normal file
5
scripts/README.md
Normal file
@ -0,0 +1,5 @@
|
||||
# Mac OS Region Definitions
|
||||
|
||||
This folder contains the script and region definitions for the Mac OS toolbox.
|
||||
|
||||
These constants are extracted from the `Script.h` file in Universal Interfaces.
|
44
scripts/extract.py
Normal file
44
scripts/extract.py
Normal file
@ -0,0 +1,44 @@
|
||||
"""Extract script and region constants from Script.h."""
|
||||
import csv
|
||||
import re
|
||||
import sys
|
||||
|
||||
from typing import List, Tuple
|
||||
|
||||
Item = Tuple[str, int]
|
||||
|
||||
def index_of(data: List[Item], key: str) -> int:
|
||||
for i, (name, _) in enumerate(data):
|
||||
if name == key:
|
||||
return i
|
||||
raise ValueError('missing value: {!r}'.format(key))
|
||||
|
||||
def slice(data: List[Item], first: str, last: str) -> List[Item]:
|
||||
return data[index_of(data, first):index_of(data, last)+1]
|
||||
|
||||
def write_csv(fname: str, data: List[Item]) -> None:
|
||||
with open(fname, 'w') as fp:
|
||||
w = csv.writer(fp)
|
||||
w.writerow(['Name', 'Value'])
|
||||
for item in data:
|
||||
w.writerow(item)
|
||||
|
||||
def main(argv: List[str]) -> None:
|
||||
if len(argv) != 1:
|
||||
print('usage: script_gen.py <Script.h>', file=sys.stderr)
|
||||
raise SystemExit(2)
|
||||
with open(argv[0], 'rb') as fp:
|
||||
data = fp.read()
|
||||
scripts: List[Item] = []
|
||||
regions: List[Item] = []
|
||||
for item in re.finditer(rb'^\s*(\w+)\s*=\s*(\d+)', data, re.MULTILINE):
|
||||
name, value = item.groups()
|
||||
if name.startswith(b'sm'):
|
||||
scripts.append((name.decode('ASCII'), int(value)))
|
||||
elif name.startswith(b'ver'):
|
||||
regions.append((name.decode('ASCII'), int(value)))
|
||||
write_csv('script.csv', slice(scripts, 'smRoman', 'smUninterp'))
|
||||
write_csv('region.csv', slice(regions, 'verUS', 'verGreenland'))
|
||||
|
||||
if __name__ == '__main__':
|
||||
main(sys.argv[1:])
|
101
scripts/region.csv
Normal file
101
scripts/region.csv
Normal file
@ -0,0 +1,101 @@
|
||||
Name,Value
|
||||
verUS,0
|
||||
verFrance,1
|
||||
verBritain,2
|
||||
verGermany,3
|
||||
verItaly,4
|
||||
verNetherlands,5
|
||||
verFlemish,6
|
||||
verSweden,7
|
||||
verSpain,8
|
||||
verDenmark,9
|
||||
verPortugal,10
|
||||
verFrCanada,11
|
||||
verNorway,12
|
||||
verIsrael,13
|
||||
verJapan,14
|
||||
verAustralia,15
|
||||
verArabic,16
|
||||
verFinland,17
|
||||
verFrSwiss,18
|
||||
verGrSwiss,19
|
||||
verGreece,20
|
||||
verIceland,21
|
||||
verMalta,22
|
||||
verCyprus,23
|
||||
verTurkey,24
|
||||
verYugoCroatian,25
|
||||
verNetherlandsComma,26
|
||||
verBelgiumLuxPoint,27
|
||||
verCanadaComma,28
|
||||
verCanadaPoint,29
|
||||
vervariantPortugal,30
|
||||
vervariantNorway,31
|
||||
vervariantDenmark,32
|
||||
verIndiaHindi,33
|
||||
verPakistanUrdu,34
|
||||
verTurkishModified,35
|
||||
verItalianSwiss,36
|
||||
verInternational,37
|
||||
verRomania,39
|
||||
verGreecePoly,40
|
||||
verLithuania,41
|
||||
verPoland,42
|
||||
verHungary,43
|
||||
verEstonia,44
|
||||
verLatvia,45
|
||||
verSami,46
|
||||
verFaroeIsl,47
|
||||
verIran,48
|
||||
verRussia,49
|
||||
verIreland,50
|
||||
verKorea,51
|
||||
verChina,52
|
||||
verTaiwan,53
|
||||
verThailand,54
|
||||
verScriptGeneric,55
|
||||
verCzech,56
|
||||
verSlovak,57
|
||||
verFarEastGeneric,58
|
||||
verMagyar,59
|
||||
verBengali,60
|
||||
verByeloRussian,61
|
||||
verUkraine,62
|
||||
verGreeceAlt,64
|
||||
verSerbian,65
|
||||
verSlovenian,66
|
||||
verMacedonian,67
|
||||
verCroatia,68
|
||||
verGermanReformed,70
|
||||
verBrazil,71
|
||||
verBulgaria,72
|
||||
verCatalonia,73
|
||||
verMultilingual,74
|
||||
verScottishGaelic,75
|
||||
verManxGaelic,76
|
||||
verBreton,77
|
||||
verNunavut,78
|
||||
verWelsh,79
|
||||
verIrishGaelicScript,81
|
||||
verEngCanada,82
|
||||
verBhutan,83
|
||||
verArmenian,84
|
||||
verGeorgian,85
|
||||
verSpLatinAmerica,86
|
||||
verTonga,88
|
||||
verFrenchUniversal,91
|
||||
verAustria,92
|
||||
verGujarati,94
|
||||
verPunjabi,95
|
||||
verIndiaUrdu,96
|
||||
verVietnam,97
|
||||
verFrBelgium,98
|
||||
verUzbek,99
|
||||
verSingapore,100
|
||||
verNynorsk,101
|
||||
verAfrikaans,102
|
||||
verEsperanto,103
|
||||
verMarathi,104
|
||||
verTibetan,105
|
||||
verNepal,106
|
||||
verGreenland,107
|
|
35
scripts/script.csv
Normal file
35
scripts/script.csv
Normal file
@ -0,0 +1,35 @@
|
||||
Name,Value
|
||||
smRoman,0
|
||||
smJapanese,1
|
||||
smTradChinese,2
|
||||
smKorean,3
|
||||
smArabic,4
|
||||
smHebrew,5
|
||||
smGreek,6
|
||||
smCyrillic,7
|
||||
smRSymbol,8
|
||||
smDevanagari,9
|
||||
smGurmukhi,10
|
||||
smGujarati,11
|
||||
smOriya,12
|
||||
smBengali,13
|
||||
smTamil,14
|
||||
smTelugu,15
|
||||
smKannada,16
|
||||
smMalayalam,17
|
||||
smSinhalese,18
|
||||
smBurmese,19
|
||||
smKhmer,20
|
||||
smThai,21
|
||||
smLao,22
|
||||
smGeorgian,23
|
||||
smArmenian,24
|
||||
smSimpChinese,25
|
||||
smTibetan,26
|
||||
smMongolian,27
|
||||
smEthiopic,28
|
||||
smGeez,28
|
||||
smCentralEuroRoman,29
|
||||
smVietnamese,30
|
||||
smExtArabic,31
|
||||
smUninterp,32
|
|
Loading…
Reference in New Issue
Block a user