From b4280fdfe0a39fa09366ee092e860453473ae4db Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Mon, 19 Aug 2019 21:58:11 -0400 Subject: [PATCH] board_pins: Improve config error checking Signed-off-by: Kevin O'Connor --- klippy/extras/board_pins.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/klippy/extras/board_pins.py b/klippy/extras/board_pins.py index d8084b02..d8388cbd 100644 --- a/klippy/extras/board_pins.py +++ b/klippy/extras/board_pins.py @@ -8,10 +8,15 @@ class PrinterBoardAliases: def __init__(self, config, chip_name): ppins = config.get_printer().lookup_object('pins') pin_resolver = ppins.get_pin_resolver(chip_name) - aliases = config.get("aliases") + aliases = config.get("aliases").strip() + if aliases.endswith(','): + aliases = aliases[:-1] parts = [a.split('=', 1) for a in aliases.split(',')] - for name, value in parts: - name, value = name.strip(), value.strip() + for pair in parts: + if len(pair) != 2: + raise ppins.error("Unable to parse aliases in %s" + % (config.get_name(),)) + name, value = [s.strip() for s in pair] if value.startswith('<') and value.endswith('>'): pin_resolver.reserve_pin(name, value) else: