summaryrefslogtreecommitdiffstats
path: root/lib/python/qmk
diff options
context:
space:
mode:
Diffstat (limited to 'lib/python/qmk')
-rwxr-xr-xlib/python/qmk/cli/generate/config_h.py3
-rwxr-xr-xlib/python/qmk/cli/generate/layouts.py6
-rw-r--r--lib/python/qmk/info.py22
-rw-r--r--lib/python/qmk/keymap.py2
-rw-r--r--lib/python/qmk/tests/test_cli_commands.py4
5 files changed, 6 insertions, 31 deletions
diff --git a/lib/python/qmk/cli/generate/config_h.py b/lib/python/qmk/cli/generate/config_h.py
index a26dcdf7d7..a2178bf1e9 100755
--- a/lib/python/qmk/cli/generate/config_h.py
+++ b/lib/python/qmk/cli/generate/config_h.py
@@ -117,9 +117,10 @@ def generate_config_items(kb_info_json, config_h_lines):
config_h_lines.append(f'# define {key} {value}')
config_h_lines.append(f'#endif // {key}')
elif key_type == 'str':
+ escaped_str = config_value.replace('\\', '\\\\').replace('"', '\\"')
config_h_lines.append('')
config_h_lines.append(f'#ifndef {config_key}')
- config_h_lines.append(f'# define {config_key} "{config_value}"')
+ config_h_lines.append(f'# define {config_key} "{escaped_str}"')
config_h_lines.append(f'#endif // {config_key}')
elif key_type == 'bcd_version':
(major, minor, revision) = config_value.split('.')
diff --git a/lib/python/qmk/cli/generate/layouts.py b/lib/python/qmk/cli/generate/layouts.py
index 193633baf6..8336f36b50 100755
--- a/lib/python/qmk/cli/generate/layouts.py
+++ b/lib/python/qmk/cli/generate/layouts.py
@@ -9,12 +9,6 @@ from qmk.keyboard import keyboard_completer, keyboard_folder
from qmk.path import is_keyboard, normpath
from qmk.commands import dump_lines
-usb_properties = {
- 'vid': 'VENDOR_ID',
- 'pid': 'PRODUCT_ID',
- 'device_ver': 'DEVICE_VER',
-}
-
@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")
diff --git a/lib/python/qmk/info.py b/lib/python/qmk/info.py
index 7460d84ad3..834f7d9170 100644
--- a/lib/python/qmk/info.py
+++ b/lib/python/qmk/info.py
@@ -437,19 +437,6 @@ def _extract_matrix_info(info_data, config_c):
return info_data
-# TODO: kill off usb.device_ver in favor of usb.device_version
-def _extract_device_version(info_data):
- if info_data.get('usb'):
- if info_data['usb'].get('device_version') and not info_data['usb'].get('device_ver'):
- (major, minor, revision) = info_data['usb']['device_version'].split('.', 3)
- info_data['usb']['device_ver'] = f'0x{major.zfill(2)}{minor}{revision}'
- if not info_data['usb'].get('device_version') and info_data['usb'].get('device_ver'):
- major = int(info_data['usb']['device_ver'][2:4])
- minor = int(info_data['usb']['device_ver'][4])
- revision = int(info_data['usb']['device_ver'][5])
- info_data['usb']['device_version'] = f'{major}.{minor}.{revision}'
-
-
def _config_to_json(key_type, config_value):
"""Convert config value using spec
"""
@@ -479,7 +466,7 @@ def _config_to_json(key_type, config_value):
return int(config_value)
elif key_type == 'str':
- return config_value.strip('"')
+ return config_value.strip('"').replace('\\"', '"').replace('\\\\', '\\')
elif key_type == 'bcd_version':
major = int(config_value[2:4])
@@ -535,7 +522,6 @@ def _extract_config_h(info_data, config_c):
_extract_split_right_pins(info_data, config_c)
_extract_encoders(info_data, config_c)
_extract_split_encoders(info_data, config_c)
- _extract_device_version(info_data)
return info_data
@@ -755,9 +741,6 @@ def arm_processor_rules(info_data, rules):
info_data['processor_type'] = 'arm'
info_data['protocol'] = 'ChibiOS'
- if 'bootloader' not in info_data:
- info_data['bootloader'] = 'unknown'
-
if 'STM32' in info_data['processor']:
info_data['platform'] = 'STM32'
elif 'MCU_SERIES' in rules:
@@ -775,9 +758,6 @@ def avr_processor_rules(info_data, rules):
info_data['platform'] = rules['ARCH'] if 'ARCH' in rules else 'unknown'
info_data['protocol'] = 'V-USB' if rules.get('MCU') in VUSB_PROCESSORS else 'LUFA'
- if 'bootloader' not in info_data:
- info_data['bootloader'] = 'atmel-dfu'
-
# FIXME(fauxpark/anyone): Eventually we should detect the protocol by looking at PROTOCOL inherited from mcu_selection.mk:
# info_data['protocol'] = 'V-USB' if rules.get('PROTOCOL') == 'VUSB' else 'LUFA'
diff --git a/lib/python/qmk/keymap.py b/lib/python/qmk/keymap.py
index f317f4d11e..fc1421962f 100644
--- a/lib/python/qmk/keymap.py
+++ b/lib/python/qmk/keymap.py
@@ -412,7 +412,7 @@ def list_keymaps(keyboard, c=True, json=True, additional_files=None, fullpath=Fa
rules = rules_mk(keyboard)
names = set()
- if rules:
+ if rules is not None:
keyboards_dir = Path('keyboards')
kb_path = keyboards_dir / keyboard
diff --git a/lib/python/qmk/tests/test_cli_commands.py b/lib/python/qmk/tests/test_cli_commands.py
index fde8b079a3..185abb5f21 100644
--- a/lib/python/qmk/tests/test_cli_commands.py
+++ b/lib/python/qmk/tests/test_cli_commands.py
@@ -265,8 +265,8 @@ def test_generate_config_h():
check_returncode(result)
assert '# define DEVICE_VER 0x0001' in result.stdout
assert '# define DIODE_DIRECTION COL2ROW' in result.stdout
- assert '# define MANUFACTURER none' in result.stdout
- assert '# define PRODUCT pytest' in result.stdout
+ assert '# define MANUFACTURER "none"' in result.stdout
+ assert '# define PRODUCT "pytest"' in result.stdout
assert '# define PRODUCT_ID 0x6465' in result.stdout
assert '# define VENDOR_ID 0xFEED' in result.stdout
assert '# define MATRIX_COLS 1' in result.stdout