Skip to content

Commit

Permalink
make flake8 happy
Browse files Browse the repository at this point in the history
  • Loading branch information
skullydazed committed Dec 1, 2020
1 parent f13eda0 commit f6c912e
Showing 1 changed file with 34 additions and 14 deletions.
48 changes: 34 additions & 14 deletions lib/python/qmk/cli/generate/config_h.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,23 @@ def layout_aliases(layout_aliases):
return '\n'.join(aliases)


def matrix_pins(matrix_pins):
"""Add the matrix config to the config.h.
"""
pins = []

if 'direct' in matrix_pins:
pins.append(direct_pins(matrix_pins['direct']))

if 'cols' in matrix_pins:
pins.append(col_pins(matrix_pins['cols']))

if 'rows' in matrix_pins:
pins.append(row_pins(matrix_pins['rows']))

return '\n'.join(pins)


def rgblight(rgblight):
"""Return the config.h lines that setup rgblight.
"""
Expand Down Expand Up @@ -161,6 +178,21 @@ def rgblight(rgblight):
return '\n'.join(rgblight_config)


def usb_properties(usb_props):
"""Return the config.h lines that setup USB params.
"""
usb_lines = []

for info_name, config_name in usb_props.items():
if info_name in usb_props:
usb_lines.append('')
usb_lines.append('#ifndef ' + config_name)
usb_lines.append('# define %s %s' % (config_name, usb_props[info_name]))
usb_lines.append('#endif // ' + config_name)

return '\n'.join(usb_lines)


@cli.argument('-o', '--output', arg_only=True, type=normpath, help='File to write to')
@cli.argument('-q', '--quiet', arg_only=True, action='store_true', help="Quiet mode, only output error messages")
@cli.argument('-kb', '--keyboard', help='Keyboard to generate config.h for.')
Expand Down Expand Up @@ -205,22 +237,10 @@ def generate_config_h(cli):
config_h_lines.append(rgblight(kb_info_json['rgblight']))

if 'matrix_pins' in kb_info_json:
if 'direct' in kb_info_json['matrix_pins']:
config_h_lines.append(direct_pins(kb_info_json['matrix_pins']['direct']))

if 'cols' in kb_info_json['matrix_pins']:
config_h_lines.append(col_pins(kb_info_json['matrix_pins']['cols']))

if 'rows' in kb_info_json['matrix_pins']:
config_h_lines.append(row_pins(kb_info_json['matrix_pins']['rows']))
config_h_lines.append(matrix_pins(kb_info_json['matrix_pins']))

if 'usb' in kb_info_json:
for info_name, config_name in usb_properties.items():
if info_name in kb_info_json['usb']:
config_h_lines.append('')
config_h_lines.append('#ifndef ' + config_name)
config_h_lines.append('# define %s %s' % (config_name, kb_info_json['usb'][info_name]))
config_h_lines.append('#endif // ' + config_name)
config_h_lines.append(usb_properties(kb_info_json['usb']))

# Show the results
config_h = '\n'.join(config_h_lines)
Expand Down

0 comments on commit f6c912e

Please sign in to comment.