CLI: Improve error messages when layout key matrix row/col is OOB (#21640)
This commit is contained in:
parent
fa4d51dab7
commit
030511ece3
|
@ -37,14 +37,19 @@ def _generate_layouts(keyboard, kb_info_json):
|
||||||
row, col = key_data['matrix']
|
row, col = key_data['matrix']
|
||||||
identifier = f'k{ROW_LETTERS[row]}{COL_LETTERS[col]}'
|
identifier = f'k{ROW_LETTERS[row]}{COL_LETTERS[col]}'
|
||||||
|
|
||||||
try:
|
if row >= row_num or col >= col_num:
|
||||||
layout_matrix[row][col] = identifier
|
|
||||||
layout_keys.append(identifier)
|
|
||||||
except IndexError:
|
|
||||||
key_name = key_data.get('label', identifier)
|
key_name = key_data.get('label', identifier)
|
||||||
cli.log.error(f'{keyboard}/{layout_name}: Matrix data out of bounds at index {index} ({key_name}): [{row}, {col}]')
|
if row >= row_num:
|
||||||
|
cli.log.error(f'{keyboard}/{layout_name}: Matrix row for key {index} ({key_name}) is {row} but must be less than {row_num}')
|
||||||
|
|
||||||
|
if col >= col_num:
|
||||||
|
cli.log.error(f'{keyboard}/{layout_name}: Matrix column for key {index} ({key_name}) is {col} but must be less than {col_num}')
|
||||||
|
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
layout_matrix[row][col] = identifier
|
||||||
|
layout_keys.append(identifier)
|
||||||
|
|
||||||
lines.append('')
|
lines.append('')
|
||||||
lines.append(f'#define {layout_name}({", ".join(layout_keys)}) {{ \\')
|
lines.append(f'#define {layout_name}({", ".join(layout_keys)}) {{ \\')
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue