make flake8 happy
This commit is contained in:
parent
2a67ff690e
commit
56ef80216a
2 changed files with 50 additions and 39 deletions
|
@ -8,9 +8,10 @@ from qmk.path import is_keyboard, normpath
|
||||||
|
|
||||||
info_to_rules = {
|
info_to_rules = {
|
||||||
'bootloader': 'BOOTLOADER',
|
'bootloader': 'BOOTLOADER',
|
||||||
'processor': 'MCU'
|
'processor': 'MCU',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@cli.argument('-o', '--output', arg_only=True, type=normpath, help='File to write to')
|
@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('-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.')
|
@cli.argument('-kb', '--keyboard', help='Keyboard to generate config.h for.')
|
||||||
|
@ -42,7 +43,7 @@ def generate_rules_mk(cli):
|
||||||
if 'features' in kb_info_json:
|
if 'features' in kb_info_json:
|
||||||
for feature, enabled in kb_info_json['features'].items():
|
for feature, enabled in kb_info_json['features'].items():
|
||||||
if feature == 'bootmagic_lite' and enabled:
|
if feature == 'bootmagic_lite' and enabled:
|
||||||
rules_mk_lines.append(f'BOOTMAGIC_ENABLE := lite')
|
rules_mk_lines.append('BOOTMAGIC_ENABLE := lite')
|
||||||
else:
|
else:
|
||||||
feature = feature.upper()
|
feature = feature.upper()
|
||||||
enabled = 'yes' if enabled else 'no'
|
enabled = 'yes' if enabled else 'no'
|
||||||
|
|
|
@ -234,14 +234,14 @@ def _extract_features(info_data, rules):
|
||||||
# Special handling for bootmagic which also supports a "lite" mode.
|
# Special handling for bootmagic which also supports a "lite" mode.
|
||||||
if rules.get('BOOTMAGIC_ENABLE') == 'lite':
|
if rules.get('BOOTMAGIC_ENABLE') == 'lite':
|
||||||
rules['BOOTMAGIC_LITE_ENABLE'] = 'on'
|
rules['BOOTMAGIC_LITE_ENABLE'] = 'on'
|
||||||
del(rules['BOOTMAGIC_ENABLE'])
|
del rules['BOOTMAGIC_ENABLE']
|
||||||
if rules.get('BOOTMAGIC_ENABLE') == 'full':
|
if rules.get('BOOTMAGIC_ENABLE') == 'full':
|
||||||
rules['BOOTMAGIC_ENABLE'] = 'on'
|
rules['BOOTMAGIC_ENABLE'] = 'on'
|
||||||
|
|
||||||
# Skip non-boolean features we haven't implemented special handling for
|
# Skip non-boolean features we haven't implemented special handling for
|
||||||
for feature in 'HAPTIC_ENABLE', 'QWIIC_ENABLE':
|
for feature in 'HAPTIC_ENABLE', 'QWIIC_ENABLE':
|
||||||
if rules.get(feature):
|
if rules.get(feature):
|
||||||
del(rules[feature])
|
del rules[feature]
|
||||||
|
|
||||||
# Process the rest of the rules as booleans
|
# Process the rest of the rules as booleans
|
||||||
for key, value in rules.items():
|
for key, value in rules.items():
|
||||||
|
@ -337,43 +337,21 @@ def _extract_rgblight(info_data, config_c):
|
||||||
return info_data
|
return info_data
|
||||||
|
|
||||||
|
|
||||||
def _extract_matrix_info(info_data, config_c):
|
def _extract_pins(pins):
|
||||||
"""Populate the matrix information.
|
"""Returns a list of pins from a comma separated string of pins.
|
||||||
"""
|
"""
|
||||||
row_pins = config_c.get('MATRIX_ROW_PINS', '').replace('{', '').replace('}', '').strip()
|
pins = [pin.strip() for pin in pins.split(',') if pin]
|
||||||
col_pins = config_c.get('MATRIX_COL_PINS', '').replace('{', '').replace('}', '').strip()
|
|
||||||
direct_pins = config_c.get('DIRECT_PINS', '').replace(' ', '')[1:-1]
|
|
||||||
|
|
||||||
if 'MATRIX_ROWS' in config_c and 'MATRIX_COLS' in config_c:
|
for pin in pins:
|
||||||
if 'matrix_size' in info_data:
|
if pin[0] not in 'ABCDEFGHIJK' or not pin[1].isdigit():
|
||||||
_log_warning(info_data, 'Matrix size is specified in both info.json and config.h, the config.h values win.')
|
raise ValueError(f'Invalid pin: {pin}')
|
||||||
|
|
||||||
info_data['matrix_size'] = {
|
return pins
|
||||||
'rows': compute(config_c.get('MATRIX_ROWS', '0')),
|
|
||||||
'cols': compute(config_c.get('MATRIX_COLS', '0')),
|
|
||||||
}
|
|
||||||
|
|
||||||
if row_pins and col_pins:
|
|
||||||
if 'matrix_pins' in info_data:
|
|
||||||
_log_warning(info_data, 'Matrix pins are specified in both info.json and config.h, the config.h values win.')
|
|
||||||
|
|
||||||
info_data['matrix_pins'] = {}
|
|
||||||
|
|
||||||
# FIXME(skullydazed/anyone): Should really check every pin, not just the first
|
|
||||||
if row_pins:
|
|
||||||
row_pins = [pin.strip() for pin in row_pins.split(',') if pin]
|
|
||||||
if row_pins[0][0] in 'ABCDEFGHIJK' and row_pins[0][1].isdigit():
|
|
||||||
info_data['matrix_pins']['rows'] = row_pins
|
|
||||||
|
|
||||||
if col_pins:
|
|
||||||
col_pins = [pin.strip() for pin in col_pins.split(',') if pin]
|
|
||||||
if col_pins[0][0] in 'ABCDEFGHIJK' and col_pins[0][1].isdigit():
|
|
||||||
info_data['matrix_pins']['cols'] = col_pins
|
|
||||||
|
|
||||||
if direct_pins:
|
|
||||||
if 'matrix_pins' in info_data:
|
|
||||||
_log_warning(info_data, 'Direct pins are specified in both info.json and config.h, the config.h values win.')
|
|
||||||
|
|
||||||
|
def _extract_direct_matrix(info_data, direct_pins):
|
||||||
|
"""
|
||||||
|
"""
|
||||||
info_data['matrix_pins'] = {}
|
info_data['matrix_pins'] = {}
|
||||||
direct_pin_array = []
|
direct_pin_array = []
|
||||||
|
|
||||||
|
@ -395,7 +373,39 @@ def _extract_matrix_info(info_data, config_c):
|
||||||
|
|
||||||
direct_pin_array[-1].append(pin)
|
direct_pin_array[-1].append(pin)
|
||||||
|
|
||||||
info_data['matrix_pins']['direct'] = direct_pin_array
|
return direct_pin_array
|
||||||
|
|
||||||
|
|
||||||
|
def _extract_matrix_info(info_data, config_c):
|
||||||
|
"""Populate the matrix information.
|
||||||
|
"""
|
||||||
|
row_pins = config_c.get('MATRIX_ROW_PINS', '').replace('{', '').replace('}', '').strip()
|
||||||
|
col_pins = config_c.get('MATRIX_COL_PINS', '').replace('{', '').replace('}', '').strip()
|
||||||
|
direct_pins = config_c.get('DIRECT_PINS', '').replace(' ', '')[1:-1]
|
||||||
|
|
||||||
|
if 'MATRIX_ROWS' in config_c and 'MATRIX_COLS' in config_c:
|
||||||
|
if 'matrix_size' in info_data:
|
||||||
|
_log_warning(info_data, 'Matrix size is specified in both info.json and config.h, the config.h values win.')
|
||||||
|
|
||||||
|
info_data['matrix_size'] = {
|
||||||
|
'cols': compute(config_c.get('MATRIX_COLS', '0')),
|
||||||
|
'rows': compute(config_c.get('MATRIX_ROWS', '0')),
|
||||||
|
}
|
||||||
|
|
||||||
|
if row_pins and col_pins:
|
||||||
|
if 'matrix_pins' in info_data:
|
||||||
|
_log_warning(info_data, 'Matrix pins are specified in both info.json and config.h, the config.h values win.')
|
||||||
|
|
||||||
|
info_data['matrix_pins'] = {
|
||||||
|
'cols': _extract_pins(col_pins),
|
||||||
|
'rows': _extract_pins(row_pins),
|
||||||
|
}
|
||||||
|
|
||||||
|
if direct_pins:
|
||||||
|
if 'matrix_pins' in info_data:
|
||||||
|
_log_warning(info_data, 'Direct pins are specified in both info.json and config.h, the config.h values win.')
|
||||||
|
|
||||||
|
info_data['matrix_pins']['direct'] = _extract_direct_matrix(info_data, direct_pins)
|
||||||
|
|
||||||
return info_data
|
return info_data
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue