diff options
Diffstat (limited to 'lib/python/qmk')
-rwxr-xr-x | lib/python/qmk/cli/kle2json.py | 10 | ||||
-rw-r--r-- | lib/python/qmk/tests/test_cli_commands.py | 2 |
2 files changed, 6 insertions, 6 deletions
diff --git a/lib/python/qmk/cli/kle2json.py b/lib/python/qmk/cli/kle2json.py index 22eb515df..5a4e97e3a 100755 --- a/lib/python/qmk/cli/kle2json.py +++ b/lib/python/qmk/cli/kle2json.py | |||
@@ -31,7 +31,7 @@ class CustomJSONEncoder(json.JSONEncoder): | |||
31 | @cli.subcommand('Convert a KLE layout to a Configurator JSON') | 31 | @cli.subcommand('Convert a KLE layout to a Configurator JSON') |
32 | def kle2json(cli): | 32 | def kle2json(cli): |
33 | """Convert a KLE layout to QMK's layout format. | 33 | """Convert a KLE layout to QMK's layout format. |
34 | """ # If filename is a path | 34 | """ # If filename is a path |
35 | if cli.args.filename.startswith("/") or cli.args.filename.startswith("./"): | 35 | if cli.args.filename.startswith("/") or cli.args.filename.startswith("./"): |
36 | file_path = Path(cli.args.filename) | 36 | file_path = Path(cli.args.filename) |
37 | # Otherwise assume it is a file name | 37 | # Otherwise assume it is a file name |
@@ -45,7 +45,7 @@ def kle2json(cli): | |||
45 | # Check if info.json exists, allow overwrite with force | 45 | # Check if info.json exists, allow overwrite with force |
46 | if Path(out_path, "info.json").exists() and not cli.args.force: | 46 | if Path(out_path, "info.json").exists() and not cli.args.force: |
47 | cli.log.error('File {fg_cyan}%s/info.json{style_reset_all} already exists, use -f or --force to overwrite.', str(out_path)) | 47 | cli.log.error('File {fg_cyan}%s/info.json{style_reset_all} already exists, use -f or --force to overwrite.', str(out_path)) |
48 | return False; | 48 | return False |
49 | try: | 49 | try: |
50 | # Convert KLE raw to x/y coordinates (using kle2xy package from skullydazed) | 50 | # Convert KLE raw to x/y coordinates (using kle2xy package from skullydazed) |
51 | kle = KLE2xy(raw_code) | 51 | kle = KLE2xy(raw_code) |
@@ -65,11 +65,9 @@ def kle2json(cli): | |||
65 | }}, | 65 | }}, |
66 | ) | 66 | ) |
67 | # Initialize keyboard with json encoded from ordered dict | 67 | # Initialize keyboard with json encoded from ordered dict |
68 | keyboard = json.dumps(keyboard, indent=4, separators=( | 68 | keyboard = json.dumps(keyboard, indent=4, separators=(', ', ': '), sort_keys=False, cls=CustomJSONEncoder) |
69 | ', ', ': '), sort_keys=False, cls=CustomJSONEncoder) | ||
70 | # Initialize layout with kle2qmk from converter module | 69 | # Initialize layout with kle2qmk from converter module |
71 | layout = json.dumps(kle2qmk(kle), separators=( | 70 | layout = json.dumps(kle2qmk(kle), separators=(', ', ':'), cls=CustomJSONEncoder) |
72 | ', ', ':'), cls=CustomJSONEncoder) | ||
73 | # Replace layout in keyboard json | 71 | # Replace layout in keyboard json |
74 | keyboard = keyboard.replace('"LAYOUT_JSON_HERE"', layout) | 72 | keyboard = keyboard.replace('"LAYOUT_JSON_HERE"', layout) |
75 | # Write our info.json | 73 | # Write our info.json |
diff --git a/lib/python/qmk/tests/test_cli_commands.py b/lib/python/qmk/tests/test_cli_commands.py index d91af992a..85d4d91af 100644 --- a/lib/python/qmk/tests/test_cli_commands.py +++ b/lib/python/qmk/tests/test_cli_commands.py | |||
@@ -19,9 +19,11 @@ def test_config(): | |||
19 | assert result.returncode == 0 | 19 | assert result.returncode == 0 |
20 | assert 'general.color' in result.stdout | 20 | assert 'general.color' in result.stdout |
21 | 21 | ||
22 | |||
22 | def test_kle2json(): | 23 | def test_kle2json(): |
23 | assert check_subcommand('kle2json', 'kle.txt', '-f').returncode == 0 | 24 | assert check_subcommand('kle2json', 'kle.txt', '-f').returncode == 0 |
24 | 25 | ||
26 | |||
25 | def test_doctor(): | 27 | def test_doctor(): |
26 | result = check_subcommand('doctor') | 28 | result = check_subcommand('doctor') |
27 | assert result.returncode == 0 | 29 | assert result.returncode == 0 |