summaryrefslogtreecommitdiff
path: root/util/lang_conv.py
diff options
context:
space:
mode:
authorJoel Challis <git@zvecr.com>2023-01-01 00:46:17 +0000
committerGitHub <noreply@github.com>2023-01-01 11:46:17 +1100
commit5a3594366f2bd8a4aed34f6d085d9c516b9dbc32 (patch)
treec37ea68cbb1bf1e409f7d299e4a87167c6d94f09 /util/lang_conv.py
parent422fd8aed8d7a985a4f090deb0d166ec81db8cd9 (diff)
Initial DD keycode regen workflow (#19400)
Diffstat (limited to 'util/lang_conv.py')
-rw-r--r--util/lang_conv.py65
1 files changed, 0 insertions, 65 deletions
diff --git a/util/lang_conv.py b/util/lang_conv.py
deleted file mode 100644
index a0da6c392d..0000000000
--- a/util/lang_conv.py
+++ /dev/null
@@ -1,65 +0,0 @@
-from pathlib import Path
-
-langs = set()
-files = Path('quantum/keymap_extras/').glob('keymap_*.h')
-for file in files:
- langs.add(file.stem.replace('keymap_', ''))
-
-for lang in langs:
- try:
- file = Path(f'quantum/keymap_extras/keymap_{lang}.h')
- print(f'Reading:{file}')
- collect = None
- out = []
- out += ['{']
- out += [' "aliases": {']
- lines = file.read_text(encoding='utf-8').split('\n')
- for line in lines:
-
- if line.startswith("// Row"):
- # print(line)
- continue
- elif line.startswith("/*******************************************************************************"):
- raise Exception(f'Skipping:{file}')
- elif '/*' in line:
- collect = [line]
- elif '*/' in line:
- collect += [line]
- if 'copyright' in collect[0].lower():
- collect = None
- continue
- out += collect
- collect = None
- elif collect:
- collect += [line]
-
- elif '#define' in line:
- define = line.split()
- while len(define) < 5:
- define.append("")
-
- if define[4] == "(backslash)":
- define[4] = '\\\\'
-
- define[4] = " ".join(define[4:]).strip()
- define[4] = define[4].replace('"', '\\"')
-
- if define[4]:
- out += [f' "{define[2]}": {{']
- out += [f' "key": "{define[1]}",']
- out += [f' "label": "{define[4]}",']
- out += [f' }}']
- else:
- out += [f' "{define[2]}": {{']
- out += [f' "key": "{define[1]}"']
- out += [f' }}']
-
- out += [' }']
- out += ['}']
-
- dump = Path(f'data/constants/keycodes/extras/keycodes_{lang}_0.0.1.hjson')
- print(f'Writing:{dump}')
- dump.write_text("\n".join(out), encoding='utf-8')
-
- except Exception as e:
- print(e)