diff --git a/.github/workflows/check-layouts.yml b/.github/workflows/check-layouts.yml index 49d85a2..004b1ae 100644 --- a/.github/workflows/check-layouts.yml +++ b/.github/workflows/check-layouts.yml @@ -13,7 +13,7 @@ jobs: - name: Checkout repo uses: actions/checkout@v4 - run: python3 gen_layouts.py - - name: "Check that the generated 'layouts.xml' is uptodate, otherwise run 'python3 gen_layouts.py'" + - name: "Run 'python3 gen_layouts.py' to update generated files" run: git diff --exit-code check-layouts: name: check_layout.output @@ -22,5 +22,5 @@ jobs: - name: Checkout repo uses: actions/checkout@v4 - run: python3 check_layout.py - - name: "Check that the generated 'check_layout.output' is uptodate, otherwise run 'python3 check_layout.py'" + - name: "Fix your layout accordingly or run 'python3 check_layout.py' to promote the warnings" run: git diff --exit-code diff --git a/build.gradle b/build.gradle index 4bc1596..1f9b3a1 100644 --- a/build.gradle +++ b/build.gradle @@ -134,12 +134,8 @@ tasks.register('genLayoutsList') { tasks.register('checkKeyboardLayouts') { println "\nChecking layouts" exec { - def layouts = new File(projectDir, "srcs/layouts").listFiles().findAll { - it.name.endsWith(".xml") - } workingDir = projectDir - commandLine("python", "check_layout.py", *layouts) - standardOutput = new FileOutputStream("${projectDir}/check_layout.output") + commandLine("python", "check_layout.py") } } diff --git a/check_layout.output b/check_layout.output index 4950d2d..76e5bff 100644 --- a/check_layout.output +++ b/check_layout.output @@ -1,191 +1,37 @@ -# arab_alt -Layout includes some ASCII punctuation but not all, missing: !, ", ', +, -, /, :, ;, <, =, >, ?, [, \, ], _, |, ~ -1 warnings -# arab_hamvaj_tly -Layout includes some ASCII punctuation but not all, missing: ", %, ', ,, /, ;, <, =, >, ?, [, \, ], _, `, {, |, } -1 warnings -# arab_pc -Layout includes some ASCII punctuation but not all, missing: !, ', +, ;, ?, \, | -1 warnings -# arab_pc_ckb -Layout includes some ASCII punctuation but not all, missing: ", %, ', +, ,, ;, <, =, >, ?, `, |, ~ -1 warnings -# arab_pc_ckb_fa -Layout includes some ASCII punctuation but not all, missing: ", #, $, %, &, ', ,, /, ;, ?, @, \, ^, `, |, ~ -1 warnings -# arab_pc_hindu -Layout includes some ASCII punctuation but not all, missing: !, ', +, ;, ?, \, | -1 warnings -# arab_pc_ir -Layout includes some ASCII punctuation but not all, missing: ", %, ', ,, /, ;, <, =, >, ?, [, \, ], `, {, |, } -1 warnings -# armenian_ph_am -0 warnings -# beng_national -Layout includes some ASCII punctuation but not all, missing: $ -1 warnings -# beng_provat -Layout includes some ASCII punctuation but not all, missing: $, &, *, ., /, <, >, [, \, ], `, {, |, } -1 warnings -# cyrl_fcuzhen_mn -0 warnings -# cyrl_jcuken_kk -0 warnings -# cyrl_jcuken_ru -0 warnings -# cyrl_jcuken_uk -0 warnings -# cyrl_lynyertz_sr -0 warnings -# cyrl_ueishsht -0 warnings -# cyrl_yaverti -Layout includes some ASCII punctuation but not all, missing: ~ -1 warnings -# cyrl_yqukeng_tj -These keys are now added automatically, unexpected: f11_placeholder, f12_placeholder -1 warnings -# cyrl_yxukeng_os -Layout includes some ASCII punctuation but not all, missing: ", #, $, &, ', @, [, ], ~ -These keys are now added automatically, unexpected: f11_placeholder, f12_placeholder -2 warnings -# deva_alt -Layout includes some ASCII punctuation but not all, missing: #, $, %, &, ', (, ), +, ., /, :, <, =, >, [, \, ], ^, _, `, {, |, }, ~ -1 warnings -# deva_inscript -Duplicate keys: । -Layout includes some ASCII punctuation but not all, missing: ", $, ', ^, _, `, | -2 warnings -# deva_phonetic_in -Duplicate keys: ट -1 warnings -# georgian_mes -0 warnings -# georgian_qwerty -0 warnings -# grek_qwerty -Duplicate keys: ; -1 warnings -# guj_phonetic_in -Duplicate keys: ટ, ડ -1 warnings -# hang_dubeolsik_kr -0 warnings -# hebr_1_il -Layout includes some ASCII punctuation but not all, missing: (, ), <, >, [, ], {, } -1 warnings -# hebr_2_il -Layout includes some ASCII punctuation but not all, missing: (, ), <, >, [, ], {, } -1 warnings -# kann_kannada -Layout includes some ASCII punctuation but not all, missing: #, $, %, (, ), *, +, /, <, =, >, [, \, ], ^, `, {, |, }, ~ -1 warnings -# latn_azerty_be -0 warnings -# latn_azerty_fr -0 warnings -# latn_bepo_fr -Missing important key, missing: loc capslock -1 warnings -# latn_bone -Missing important key, missing: loc capslock -Missing programming keys, missing: loc esc, loc tab -Layout redefines the bottom row but some important keys are missing, missing: cursor_left, cursor_right, loc compose, loc end, loc home, loc page_down, loc page_up, loc switch_clipboard, loc switch_greekmath, loc voice_typing, switch_backward -3 warnings -# latn_colemak -Some keys contain whitespaces, unexpected: ́ -1 warnings -# latn_dvorak -Missing important key, missing: loc capslock -1 warnings -# latn_neo2 -Layout redefines the bottom row but some important keys are missing, missing: loc switch_clipboard -1 warnings -# latn_qwerty_az -0 warnings -# latn_qwerty_br -0 warnings -# latn_qwerty_cy -0 warnings -# latn_qwerty_cz -0 warnings -# latn_qwerty_da -0 warnings -# latn_qwerty_es -0 warnings -# latn_qwerty_et -0 warnings -# latn_qwerty_ga -0 warnings -# latn_qwerty_gb -0 warnings -# latn_qwerty_haw -0 warnings -# latn_qwerty_hu -0 warnings -# latn_qwerty_jp -0 warnings -# latn_qwerty_kk -0 warnings -# latn_qwerty_lt -0 warnings -# latn_qwerty_lv -0 warnings -# latn_qwerty_mt -0 warnings -# latn_qwerty_no -0 warnings -# latn_qwerty_pl -0 warnings -# latn_qwerty_ro -0 warnings -# latn_qwerty_se -Duplicate keys: !, ', ,, -, ., ? -1 warnings -# latn_qwerty_sk -0 warnings -# latn_qwerty_sr -0 warnings -# latn_qwerty_tly -Duplicate keys: a, c, j, q -Missing programming keys, missing: loc esc, loc tab -2 warnings -# latn_qwerty_tr -0 warnings -# latn_qwerty_us -0 warnings -# latn_qwerty_uz -0 warnings -# latn_qwerty_vi -0 warnings -# latn_qwertz -0 warnings -# latn_qwertz_cz -0 warnings -# latn_qwertz_cz_diacritics -0 warnings -# latn_qwertz_cz_multifunctional -Layout includes some ASCII punctuation but not all, missing: ` -1 warnings -# latn_qwertz_de -0 warnings -# latn_qwertz_fr_ch -0 warnings -# latn_qwertz_hu -0 warnings -# latn_qwertz_sk -Layout includes some ASCII punctuation but not all, missing: ` -1 warnings -# latn_qwertz_sq -0 warnings -# latn_workman_us -0 warnings -# shaw_imperial_en -0 warnings -# tamil_default -0 warnings -# urdu_phonetic_ur -Duplicate keys: -Layout includes some ASCII punctuation but not all, missing: <, >, ?, `, |, ~ -Some keys contain whitespaces, unexpected: -3 warnings +arab_alt: Layout includes some ASCII punctuation but not all, missing: !, ", ', +, -, /, :, ;, <, =, >, ?, [, \, ], _, |, ~ +arab_hamvaj_tly: Layout includes some ASCII punctuation but not all, missing: ", %, ', ,, /, ;, <, =, >, ?, [, \, ], _, `, {, |, } +arab_pc: Layout includes some ASCII punctuation but not all, missing: !, ', +, ;, ?, \, | +arab_pc_ckb: Layout includes some ASCII punctuation but not all, missing: ", %, ', +, ,, ;, <, =, >, ?, `, |, ~ +arab_pc_ckb_fa: Layout includes some ASCII punctuation but not all, missing: ", #, $, %, &, ', ,, /, ;, ?, @, \, ^, `, |, ~ +arab_pc_hindu: Layout includes some ASCII punctuation but not all, missing: !, ', +, ;, ?, \, | +arab_pc_ir: Layout includes some ASCII punctuation but not all, missing: ", %, ', ,, /, ;, <, =, >, ?, [, \, ], `, {, |, } +beng_national: Layout includes some ASCII punctuation but not all, missing: $ +beng_provat: Layout includes some ASCII punctuation but not all, missing: $, &, *, ., /, <, >, [, \, ], `, {, |, } +cyrl_yaverti: Layout includes some ASCII punctuation but not all, missing: ~ +cyrl_yqukeng_tj: These keys are now added automatically, unexpected: f11_placeholder, f12_placeholder +cyrl_yxukeng_os: Layout includes some ASCII punctuation but not all, missing: ", #, $, &, ', @, [, ], ~ +cyrl_yxukeng_os: These keys are now added automatically, unexpected: f11_placeholder, f12_placeholder +deva_alt: Layout includes some ASCII punctuation but not all, missing: #, $, %, &, ', (, ), +, ., /, :, <, =, >, [, \, ], ^, _, `, {, |, }, ~ +deva_inscript: Duplicate keys: । +deva_inscript: Layout includes some ASCII punctuation but not all, missing: ", $, ', ^, _, `, | +deva_phonetic_in: Duplicate keys: ट +grek_qwerty: Duplicate keys: ; +guj_phonetic_in: Duplicate keys: ટ, ડ +hebr_1_il: Layout includes some ASCII punctuation but not all, missing: (, ), <, >, [, ], {, } +hebr_2_il: Layout includes some ASCII punctuation but not all, missing: (, ), <, >, [, ], {, } +kann_kannada: Layout includes some ASCII punctuation but not all, missing: #, $, %, (, ), *, +, /, <, =, >, [, \, ], ^, `, {, |, }, ~ +latn_bepo_fr: Missing important key, missing: loc capslock +latn_bone: Missing important key, missing: loc capslock +latn_bone: Missing programming keys, missing: loc esc, loc tab +latn_bone: Layout redefines the bottom row but some important keys are missing, missing: cursor_left, cursor_right, loc compose, loc end, loc home, loc page_down, loc page_up, loc switch_clipboard, loc switch_greekmath, loc voice_typing, switch_backward +latn_colemak: Some keys contain whitespaces, unexpected: ́ +latn_dvorak: Missing important key, missing: loc capslock +latn_neo2: Layout redefines the bottom row but some important keys are missing, missing: loc switch_clipboard +latn_qwerty_se: Duplicate keys: !, ', ,, -, ., ? +latn_qwerty_tly: Duplicate keys: a, c, j, q +latn_qwerty_tly: Missing programming keys, missing: loc esc, loc tab +latn_qwertz_cz_multifunctional: Layout includes some ASCII punctuation but not all, missing: ` +latn_qwertz_sk: Layout includes some ASCII punctuation but not all, missing: ` +urdu_phonetic_ur: Duplicate keys: +urdu_phonetic_ur: Layout includes some ASCII punctuation but not all, missing: <, >, ?, `, |, ~ +urdu_phonetic_ur: Some keys contain whitespaces, unexpected: diff --git a/check_layout.py b/check_layout.py index 500b10b..ee1cbc9 100644 --- a/check_layout.py +++ b/check_layout.py @@ -1,7 +1,8 @@ import xml.etree.ElementTree as ET -import sys, os +import sys, os, glob -warning_count = 0 +layout_file_name = 0 +warnings = [] KNOWN_NOT_LAYOUT = set([ "number_row", "numpad", "pin", @@ -15,9 +16,8 @@ KEY_ATTRIBUTES = set([ ]) def warn(msg): - global warning_count - print(msg) - warning_count += 1 + global warnings + warnings.append("%s: %s" % (layout_file_name, msg)) def key_list_str(keys): return ", ".join(sorted(list(keys))) @@ -103,15 +103,17 @@ def check_layout(layout): if root.get("script") == None: warn("Layout doesn't specify a script.") -for fname in sorted(sys.argv[1:]): +for fname in sorted(glob.glob("srcs/layouts/*.xml")): layout_id, _ = os.path.splitext(os.path.basename(fname)) if layout_id in KNOWN_NOT_LAYOUT: continue + layout_file_name = layout_id layout = parse_layout(fname) if layout == None: - print("Not a layout file: %s" % layout_id) + warn("Not a layout file") else: - print("# %s" % layout_id) - warning_count = 0 check_layout(layout) - print("%d warnings" % warning_count) + +with open("check_layout.output", "w") as out: + for w in warnings: + print(w, file=out)