diff options
author | QMK Bot <hello@qmk.fm> | 2019-11-13 05:24:56 +0000 |
---|---|---|
committer | QMK Bot <hello@qmk.fm> | 2019-11-13 05:24:56 +0000 |
commit | a4c2a9b083d82d9e7d7fe3a68c0d51ae2280495f (patch) | |
tree | a1b6edbeb75442ab50b68283bea5af72b09ceccf /lib/python/qmk/cli/kle2json.py | |
parent | 7329c2d02d38f40a23d38f789de34057fd2acd42 (diff) | |
download | qmk_firmware-a4c2a9b083d82d9e7d7fe3a68c0d51ae2280495f.tar.gz qmk_firmware-a4c2a9b083d82d9e7d7fe3a68c0d51ae2280495f.zip |
format code according to conventions [skip ci]
Diffstat (limited to 'lib/python/qmk/cli/kle2json.py')
-rwxr-xr-x | lib/python/qmk/cli/kle2json.py | 10 |
1 files changed, 4 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 |