mirror of https://github.com/Desuuuu/klipper.git
pins: Improve pin description checks
Make sure whitespace isn't in the pin description. Also make sure an alias doesn't map to an invalid pin. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
c263f76f9f
commit
a94146b554
|
@ -30,6 +30,8 @@ class PinResolver:
|
||||||
if alias in self.aliases and self.aliases[alias] != pin:
|
if alias in self.aliases and self.aliases[alias] != pin:
|
||||||
raise error("Alias %s mapped to %s - can't alias to %s" % (
|
raise error("Alias %s mapped to %s - can't alias to %s" % (
|
||||||
alias, self.aliases[alias], pin))
|
alias, self.aliases[alias], pin))
|
||||||
|
if [c for c in '^~!:' if c in pin] or ''.join(pin.split()) != pin:
|
||||||
|
raise error("Invalid pin alias '%s'\n" % (pin,))
|
||||||
if pin in self.aliases:
|
if pin in self.aliases:
|
||||||
pin = self.aliases[pin]
|
pin = self.aliases[pin]
|
||||||
self.aliases[alias] = pin
|
self.aliases[alias] = pin
|
||||||
|
@ -79,7 +81,7 @@ class PrinterPins:
|
||||||
chip_name, pin = [s.strip() for s in desc.split(':', 1)]
|
chip_name, pin = [s.strip() for s in desc.split(':', 1)]
|
||||||
if chip_name not in self.chips:
|
if chip_name not in self.chips:
|
||||||
raise error("Unknown pin chip name '%s'" % (chip_name,))
|
raise error("Unknown pin chip name '%s'" % (chip_name,))
|
||||||
if [c for c in '^~!: ' if c in pin]:
|
if [c for c in '^~!:' if c in pin] or ''.join(pin.split()) != pin:
|
||||||
format = ""
|
format = ""
|
||||||
if can_pullup:
|
if can_pullup:
|
||||||
format += "[^~] "
|
format += "[^~] "
|
||||||
|
|
Loading…
Reference in New Issue