format code according to conventions [skip ci]

master
QMK Bot 2019-11-13 05:24:56 +00:00
parent 7329c2d02d
commit a4c2a9b083
3 changed files with 10 additions and 19 deletions

View File

@ -4,6 +4,7 @@
import hjson import hjson
from decimal import Decimal from decimal import Decimal
class KLE2xy(list): class KLE2xy(list):
"""Abstract interface for interacting with a KLE layout. """Abstract interface for interacting with a KLE layout.
""" """
@ -13,17 +14,7 @@ class KLE2xy(list):
self.name = name self.name = name
self.invert_y = invert_y self.invert_y = invert_y
self.key_width = Decimal('19.05') self.key_width = Decimal('19.05')
self.key_skel = { self.key_skel = {'decal': False, 'border_color': 'none', 'keycap_profile': '', 'keycap_color': 'grey', 'label_color': 'black', 'label_size': 3, 'label_style': 4, 'width': Decimal('1'), 'height': Decimal('1'), 'x': Decimal('0'), 'y': Decimal('0')}
'decal': False,
'border_color': 'none',
'keycap_profile': '',
'keycap_color': 'grey',
'label_color': 'black',
'label_size': 3,
'label_style': 4,
'width': Decimal('1'), 'height': Decimal('1'),
'x': Decimal('0'), 'y': Decimal('0')
}
self.rows = Decimal(0) self.rows = Decimal(0)
self.columns = Decimal(0) self.columns = Decimal(0)
@ -34,13 +25,13 @@ class KLE2xy(list):
def width(self): def width(self):
"""Returns the width of the keyboard plate. """Returns the width of the keyboard plate.
""" """
return (Decimal(self.columns) * self.key_width) + self.key_width/2 return (Decimal(self.columns) * self.key_width) + self.key_width / 2
@property @property
def height(self): def height(self):
"""Returns the height of the keyboard plate. """Returns the height of the keyboard plate.
""" """
return (self.rows * self.key_width) + self.key_width/2 return (self.rows * self.key_width) + self.key_width / 2
@property @property
def size(self): def size(self):

View File

@ -45,7 +45,7 @@ def kle2json(cli):
# Check if info.json exists, allow overwrite with force # Check if info.json exists, allow overwrite with force
if Path(out_path, "info.json").exists() and not cli.args.force: if Path(out_path, "info.json").exists() and not cli.args.force:
cli.log.error('File {fg_cyan}%s/info.json{style_reset_all} already exists, use -f or --force to overwrite.', str(out_path)) cli.log.error('File {fg_cyan}%s/info.json{style_reset_all} already exists, use -f or --force to overwrite.', str(out_path))
return False; return False
try: try:
# Convert KLE raw to x/y coordinates (using kle2xy package from skullydazed) # Convert KLE raw to x/y coordinates (using kle2xy package from skullydazed)
kle = KLE2xy(raw_code) kle = KLE2xy(raw_code)
@ -65,11 +65,9 @@ def kle2json(cli):
}}, }},
) )
# Initialize keyboard with json encoded from ordered dict # Initialize keyboard with json encoded from ordered dict
keyboard = json.dumps(keyboard, indent=4, separators=( keyboard = json.dumps(keyboard, indent=4, separators=(', ', ': '), sort_keys=False, cls=CustomJSONEncoder)
', ', ': '), sort_keys=False, cls=CustomJSONEncoder)
# Initialize layout with kle2qmk from converter module # Initialize layout with kle2qmk from converter module
layout = json.dumps(kle2qmk(kle), separators=( layout = json.dumps(kle2qmk(kle), separators=(', ', ':'), cls=CustomJSONEncoder)
', ', ':'), cls=CustomJSONEncoder)
# Replace layout in keyboard json # Replace layout in keyboard json
keyboard = keyboard.replace('"LAYOUT_JSON_HERE"', layout) keyboard = keyboard.replace('"LAYOUT_JSON_HERE"', layout)
# Write our info.json # Write our info.json

View File

@ -19,9 +19,11 @@ def test_config():
assert result.returncode == 0 assert result.returncode == 0
assert 'general.color' in result.stdout assert 'general.color' in result.stdout
def test_kle2json(): def test_kle2json():
assert check_subcommand('kle2json', 'kle.txt', '-f').returncode == 0 assert check_subcommand('kle2json', 'kle.txt', '-f').returncode == 0
def test_doctor(): def test_doctor():
result = check_subcommand('doctor') result = check_subcommand('doctor')
assert result.returncode == 0 assert result.returncode == 0