make flake8 happy
This commit is contained in:
parent
2a67ff690e
commit
56ef80216a
@ -8,9 +8,10 @@ from qmk.path import is_keyboard, normpath
|
||||
|
||||
info_to_rules = {
|
||||
'bootloader': 'BOOTLOADER',
|
||||
'processor': 'MCU'
|
||||
'processor': 'MCU',
|
||||
}
|
||||
|
||||
|
||||
@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.')
|
||||
@ -42,7 +43,7 @@ def generate_rules_mk(cli):
|
||||
if 'features' in kb_info_json:
|
||||
for feature, enabled in kb_info_json['features'].items():
|
||||
if feature == 'bootmagic_lite' and enabled:
|
||||
rules_mk_lines.append(f'BOOTMAGIC_ENABLE := lite')
|
||||
rules_mk_lines.append('BOOTMAGIC_ENABLE := lite')
|
||||
else:
|
||||
feature = feature.upper()
|
||||
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.
|
||||
if rules.get('BOOTMAGIC_ENABLE') == 'lite':
|
||||
rules['BOOTMAGIC_LITE_ENABLE'] = 'on'
|
||||
del(rules['BOOTMAGIC_ENABLE'])
|
||||
del rules['BOOTMAGIC_ENABLE']
|
||||
if rules.get('BOOTMAGIC_ENABLE') == 'full':
|
||||
rules['BOOTMAGIC_ENABLE'] = 'on'
|
||||
|
||||
# Skip non-boolean features we haven't implemented special handling for
|
||||
for feature in 'HAPTIC_ENABLE', 'QWIIC_ENABLE':
|
||||
if rules.get(feature):
|
||||
del(rules[feature])
|
||||
del rules[feature]
|
||||
|
||||
# Process the rest of the rules as booleans
|
||||
for key, value in rules.items():
|
||||
@ -337,43 +337,21 @@ def _extract_rgblight(info_data, config_c):
|
||||
return info_data
|
||||
|
||||
|
||||
def _extract_matrix_info(info_data, config_c):
|
||||
"""Populate the matrix information.
|
||||
def _extract_pins(pins):
|
||||
"""Returns a list of pins from a comma separated string of pins.
|
||||
"""
|
||||
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]
|
||||
pins = [pin.strip() for pin in pins.split(',') if pin]
|
||||
|
||||
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.')
|
||||
for pin in pins:
|
||||
if pin[0] not in 'ABCDEFGHIJK' or not pin[1].isdigit():
|
||||
raise ValueError(f'Invalid pin: {pin}')
|
||||
|
||||
info_data['matrix_size'] = {
|
||||
'rows': compute(config_c.get('MATRIX_ROWS', '0')),
|
||||
'cols': compute(config_c.get('MATRIX_COLS', '0')),
|
||||
}
|
||||
return pins
|
||||
|
||||
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'] = {}
|
||||
direct_pin_array = []
|
||||
|
||||
@ -395,7 +373,39 @@ def _extract_matrix_info(info_data, config_c):
|
||||
|
||||
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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user