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,6 +337,45 @@ def _extract_rgblight(info_data, config_c):
|
||||
return info_data
|
||||
|
||||
|
||||
def _extract_pins(pins):
|
||||
"""Returns a list of pins from a comma separated string of pins.
|
||||
"""
|
||||
pins = [pin.strip() for pin in pins.split(',') if pin]
|
||||
|
||||
for pin in pins:
|
||||
if pin[0] not in 'ABCDEFGHIJK' or not pin[1].isdigit():
|
||||
raise ValueError(f'Invalid pin: {pin}')
|
||||
|
||||
return pins
|
||||
|
||||
|
||||
def _extract_direct_matrix(info_data, direct_pins):
|
||||
"""
|
||||
"""
|
||||
info_data['matrix_pins'] = {}
|
||||
direct_pin_array = []
|
||||
|
||||
while direct_pins[-1] != '}':
|
||||
direct_pins = direct_pins[:-1]
|
||||
|
||||
for row in direct_pins.split('},{'):
|
||||
if row.startswith('{'):
|
||||
row = row[1:]
|
||||
|
||||
if row.endswith('}'):
|
||||
row = row[:-1]
|
||||
|
||||
direct_pin_array.append([])
|
||||
|
||||
for pin in row.split(','):
|
||||
if pin == 'NO_PIN':
|
||||
pin = None
|
||||
|
||||
direct_pin_array[-1].append(pin)
|
||||
|
||||
return direct_pin_array
|
||||
|
||||
|
||||
def _extract_matrix_info(info_data, config_c):
|
||||
"""Populate the matrix information.
|
||||
"""
|
||||
@ -349,53 +388,24 @@ def _extract_matrix_info(info_data, config_c):
|
||||
_log_warning(info_data, 'Matrix size is specified in both info.json and config.h, the config.h values win.')
|
||||
|
||||
info_data['matrix_size'] = {
|
||||
'rows': compute(config_c.get('MATRIX_ROWS', '0')),
|
||||
'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'] = {}
|
||||
|
||||
# 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
|
||||
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_pin_array = []
|
||||
|
||||
while direct_pins[-1] != '}':
|
||||
direct_pins = direct_pins[:-1]
|
||||
|
||||
for row in direct_pins.split('},{'):
|
||||
if row.startswith('{'):
|
||||
row = row[1:]
|
||||
|
||||
if row.endswith('}'):
|
||||
row = row[:-1]
|
||||
|
||||
direct_pin_array.append([])
|
||||
|
||||
for pin in row.split(','):
|
||||
if pin == 'NO_PIN':
|
||||
pin = None
|
||||
|
||||
direct_pin_array[-1].append(pin)
|
||||
|
||||
info_data['matrix_pins']['direct'] = direct_pin_array
|
||||
info_data['matrix_pins']['direct'] = _extract_direct_matrix(info_data, direct_pins)
|
||||
|
||||
return info_data
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user