diff options
author | Zach White <skullydazed@gmail.com> | 2021-01-08 00:00:15 -0800 |
---|---|---|
committer | Zach White <skullydazed@drpepper.org> | 2021-01-08 08:40:23 -0800 |
commit | 30331b383f9ef4620e47aa07e4f9af7fae9d30b3 (patch) | |
tree | 4d1a12b52d99aa3c31f6a859c9a71959159d58de /lib/python/qmk | |
parent | a828a82d59b6205a56f7d42d51217f13ffbcb0d5 (diff) | |
download | qmk_firmware-30331b383f9ef4620e47aa07e4f9af7fae9d30b3.tar.gz qmk_firmware-30331b383f9ef4620e47aa07e4f9af7fae9d30b3.zip |
fix bugs triggered by certain boards
Diffstat (limited to 'lib/python/qmk')
-rw-r--r-- | lib/python/qmk/c_parse.py | 4 | ||||
-rwxr-xr-x | lib/python/qmk/cli/generate/config_h.py | 6 | ||||
-rw-r--r-- | lib/python/qmk/info.py | 35 |
3 files changed, 29 insertions, 16 deletions
diff --git a/lib/python/qmk/c_parse.py b/lib/python/qmk/c_parse.py index 67e196f0e..0338484ec 100644 --- a/lib/python/qmk/c_parse.py +++ b/lib/python/qmk/c_parse.py | |||
@@ -9,7 +9,7 @@ from qmk.comment_remover import comment_remover | |||
9 | 9 | ||
10 | default_key_entry = {'x': -1, 'y': 0, 'w': 1} | 10 | default_key_entry = {'x': -1, 'y': 0, 'w': 1} |
11 | single_comment_regex = re.compile(r' */[/*].*$') | 11 | single_comment_regex = re.compile(r' */[/*].*$') |
12 | multi_comment_regex = re.compile(r'/\*(.|\n)*\*/', re.MULTILINE) | 12 | multi_comment_regex = re.compile(r'/\*(.|\n)*?\*/', re.MULTILINE) |
13 | 13 | ||
14 | 14 | ||
15 | def strip_line_comment(string): | 15 | def strip_line_comment(string): |
@@ -103,7 +103,7 @@ def parse_config_h_file(config_h_file, config_h=None): | |||
103 | 103 | ||
104 | if config_h_file.exists(): | 104 | if config_h_file.exists(): |
105 | config_h_text = config_h_file.read_text() | 105 | config_h_text = config_h_file.read_text() |
106 | config_h_text = config_h_text.replace('\\\n', '') | 106 | config_h_text = config_h_text.replace('\\\n', '') # Why are you here? |
107 | config_h_text = strip_multiline_comment(config_h_text) | 107 | config_h_text = strip_multiline_comment(config_h_text) |
108 | 108 | ||
109 | for linenum, line in enumerate(config_h_text.split('\n')): | 109 | for linenum, line in enumerate(config_h_text.split('\n')): |
diff --git a/lib/python/qmk/cli/generate/config_h.py b/lib/python/qmk/cli/generate/config_h.py index 15d4fbf2d..1de84de7a 100755 --- a/lib/python/qmk/cli/generate/config_h.py +++ b/lib/python/qmk/cli/generate/config_h.py | |||
@@ -64,7 +64,7 @@ def direct_pins(direct_pins): | |||
64 | rows = [] | 64 | rows = [] |
65 | 65 | ||
66 | for row in direct_pins: | 66 | for row in direct_pins: |
67 | cols = ','.join([col or 'NO_PIN' for col in row]) | 67 | cols = ','.join(map(str, [col or 'NO_PIN' for col in row])) |
68 | rows.append('{' + cols + '}') | 68 | rows.append('{' + cols + '}') |
69 | 69 | ||
70 | col_count = len(direct_pins[0]) | 70 | col_count = len(direct_pins[0]) |
@@ -88,7 +88,7 @@ def direct_pins(direct_pins): | |||
88 | def col_pins(col_pins): | 88 | def col_pins(col_pins): |
89 | """Return the config.h lines that set the column pins. | 89 | """Return the config.h lines that set the column pins. |
90 | """ | 90 | """ |
91 | cols = ','.join(col_pins) | 91 | cols = ','.join(map(str, [pin or 'NO_PIN' for pin in col_pins])) |
92 | col_num = len(col_pins) | 92 | col_num = len(col_pins) |
93 | 93 | ||
94 | return """ | 94 | return """ |
@@ -105,7 +105,7 @@ def col_pins(col_pins): | |||
105 | def row_pins(row_pins): | 105 | def row_pins(row_pins): |
106 | """Return the config.h lines that set the row pins. | 106 | """Return the config.h lines that set the row pins. |
107 | """ | 107 | """ |
108 | rows = ','.join(row_pins) | 108 | rows = ','.join(map(str, [pin or 'NO_PIN' for pin in row_pins])) |
109 | row_num = len(row_pins) | 109 | row_num = len(row_pins) |
110 | 110 | ||
111 | return """ | 111 | return """ |
diff --git a/lib/python/qmk/info.py b/lib/python/qmk/info.py index efd339115..28c281a4b 100644 --- a/lib/python/qmk/info.py +++ b/lib/python/qmk/info.py | |||
@@ -315,11 +315,10 @@ def _extract_rgblight(info_data, config_c): | |||
315 | cli.log.error('%s: config.h: Could not convert "%s" to %s: %s', info_data['keyboard_folder'], config_c[config_key], config_type.__name__, e) | 315 | cli.log.error('%s: config.h: Could not convert "%s" to %s: %s', info_data['keyboard_folder'], config_c[config_key], config_type.__name__, e) |
316 | 316 | ||
317 | for json_key, config_key in rgblight_toggles.items(): | 317 | for json_key, config_key in rgblight_toggles.items(): |
318 | if config_key in config_c: | 318 | if config_key in config_c and json_key in rgblight: |
319 | if json_key in rgblight: | 319 | _log_warning(info_data, 'RGB Light: %s is specified in both info.json and config.h, the config.h value wins.', json_key) |
320 | _log_warning(info_data, 'RGB Light: %s is specified in both info.json and config.h, the config.h value wins.', json_key) | ||
321 | 320 | ||
322 | rgblight[json_key] = config_c[config_key] | 321 | rgblight[json_key] = config_key in config_c |
323 | 322 | ||
324 | for json_key, config_key in rgblight_animations.items(): | 323 | for json_key, config_key in rgblight_animations.items(): |
325 | if config_key in config_c: | 324 | if config_key in config_c: |
@@ -337,16 +336,30 @@ def _extract_rgblight(info_data, config_c): | |||
337 | return info_data | 336 | return info_data |
338 | 337 | ||
339 | 338 | ||
340 | def _extract_pins(pins): | 339 | def _pin_name(pin): |
341 | """Returns a list of pins from a comma separated string of pins. | 340 | """Returns the proper representation for a pin. |
342 | """ | 341 | """ |
343 | pins = [pin.strip() for pin in pins.split(',') if pin] | 342 | pin = pin.strip() |
343 | |||
344 | if not pin: | ||
345 | return None | ||
346 | |||
347 | elif pin.isdigit(): | ||
348 | return int(pin) | ||
344 | 349 | ||
345 | for pin in pins: | 350 | elif pin == 'NO_PIN': |
346 | if pin[0] not in 'ABCDEFGHIJK' or not pin[1].isdigit(): | 351 | return None |
347 | raise ValueError(f'Invalid pin: {pin}') | ||
348 | 352 | ||
349 | return pins | 353 | elif pin[0] in 'ABCDEFGHIJK' and pin[1].isdigit(): |
354 | return pin | ||
355 | |||
356 | raise ValueError(f'Invalid pin: {pin}') | ||
357 | |||
358 | |||
359 | def _extract_pins(pins): | ||
360 | """Returns a list of pins from a comma separated string of pins. | ||
361 | """ | ||
362 | return [_pin_name(pin) for pin in pins.split(',')] | ||
350 | 363 | ||
351 | 364 | ||
352 | def _extract_direct_matrix(info_data, direct_pins): | 365 | def _extract_direct_matrix(info_data, direct_pins): |