f549948bbd2a2026875faab1f67ba7b8d21bb5a6

Author
Joel Challis <git@zvecr.com>
Committer
GitHub <noreply@github.com>
Date

Message

Skip parsing g_led_config when matrix_size is missing (#24739)

Diff

 1diff --git a/lib/python/qmk/info.py b/lib/python/qmk/info.py
 2index 74a62721a3d944d8eab433dccf0230531616d010..acf8da984fa76cc9e4610ceb01070e39235c0a82 100644
 3--- a/lib/python/qmk/info.py
 4+++ b/lib/python/qmk/info.py
 5@@ -773,23 +773,24 @@ def find_keyboard_c(keyboard):
 6 def _extract_led_config(info_data, keyboard):
 7     """Scan all <keyboard>.c files for led config
 8     """
 9-    cols = info_data['matrix_size']['cols']
10-    rows = info_data['matrix_size']['rows']
11-
12     for feature in ['rgb_matrix', 'led_matrix']:
13         if info_data.get('features', {}).get(feature, False) or feature in info_data:
14-
15             # Only attempt search if dd led config is missing
16             if 'layout' not in info_data.get(feature, {}):
17-                # Process
18-                for file in find_keyboard_c(keyboard):
19-                    try:
20-                        ret = find_led_config(file, cols, rows)
21-                        if ret:
22-                            info_data[feature] = info_data.get(feature, {})
23-                            info_data[feature]['layout'] = ret
24-                    except Exception as e:
25-                        _log_warning(info_data, f'led_config: {file.name}: {e}')
26+                cols = info_data.get('matrix_size', {}).get('cols')
27+                rows = info_data.get('matrix_size', {}).get('rows')
28+                if cols and rows:
29+                    # Process
30+                    for file in find_keyboard_c(keyboard):
31+                        try:
32+                            ret = find_led_config(file, cols, rows)
33+                            if ret:
34+                                info_data[feature] = info_data.get(feature, {})
35+                                info_data[feature]['layout'] = ret
36+                        except Exception as e:
37+                            _log_warning(info_data, f'led_config: {file.name}: {e}')
38+                    else:
39+                        _log_warning(info_data, 'led_config: matrix size required to parse g_led_config')
40 
41             if info_data[feature].get('layout', None) and not info_data[feature].get('led_count', None):
42                 info_data[feature]['led_count'] = len(info_data[feature]['layout'])