Slightly refine `g_led_config` parsing (#21170)

This commit is contained in:
Ryan 2023-06-09 06:08:02 +10:00 committed by GitHub
parent 4c6c387724
commit a9f677b518
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 6 deletions

View File

@ -241,19 +241,24 @@ def _parse_led_config(file, matrix_cols, matrix_rows):
position_raw = [] position_raw = []
flags = [] flags = []
found_led_config = False found_led_config_t = False
found_g_led_config = False
bracket_count = 0 bracket_count = 0
section = 0 section = 0
current_row_index = 0 current_row_index = 0
current_row = [] current_row = []
for _type, value in lex(_preprocess_c_file(file), CLexer()): for _type, value in lex(_preprocess_c_file(file), CLexer()):
# Assume g_led_config..stuff..; if not found_g_led_config:
if value == 'g_led_config': # Check for type
found_led_config = True if value == 'led_config_t':
found_led_config_t = True
# Type found, now check for name
elif found_led_config_t and value == 'g_led_config':
found_g_led_config = True
elif value == ';': elif value == ';':
found_led_config = False found_g_led_config = False
elif found_led_config: else:
# Assume bracket count hints to section of config we are within # Assume bracket count hints to section of config we are within
if value == '{': if value == '{':
bracket_count += 1 bracket_count += 1