Commit f73640ae authored by Joel Collins's avatar Joel Collins
Browse files

Updated regex for Py37

parent ad87c93a
Loading
Loading
Loading
Loading
+9 −9
Original line number Diff line number Diff line
@@ -201,13 +201,13 @@ class ExtensibleSerialInstrument(object):
        placeholders = [ #tuples of (regex matching placeholder, regex to replace it with, parse function)
            (r"%c", r".", noop),
            (r"%(\d+)c", r".{\1}", noop), #TODO support %cn where n is a number of chars
            (r"%d",r"[-+]?\d+", int),
            (r"%[eEfg]",r"[-+]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][-+]?\d+)?", float),
            (r"%i",r"[-+]?(?:0[xX][\dA-Fa-f]+|0[0-7]*|\d+)", lambda x: int(x, 0)), #0=autodetect base
            (r"%d", r"[-+]?\\d+", int),
            (r"%[eEfg]", r"[-+]?(?:\\d+(?:\.\\d*)?|\.\\d+)(?:[eE][-+]?\\d+)?", float),
            (r"%i", r"[-+]?(?:0[xX][\\dA-Fa-f]+|0[0-7]*|\\d+)", lambda x: int(x, 0)), #0=autodetect base
            (r"%o", r"[-+]?[0-7]+", lambda x: int(x, 8)), #8 means octal
            (r"%s",r"\S+",noop),
            (r"%u",r"\d+",int),
            (r"%[xX]",r"[-+]?(?:0[xX])?[\dA-Fa-f]+",lambda x: int(x, 16)), #16 forces hexadecimal
            (r"%s", r"\\s+", noop),
            (r"%u", r"\\d+", int),
            (r"%[xX]", r"[-+]?(?:0[xX])?[\\dA-Fa-f]+", lambda x: int(x, 16)), #16 forces hexadecimal
        ]
        matched_placeholders = []
        for placeholder, regex, parse_fun in placeholders:
+1 −1
Original line number Diff line number Diff line
@@ -156,7 +156,7 @@ class Sangaboard(ExtensibleSerialInstrument):

        # Request firmware version from the board
        self.firmware = self.query("version",timeout=2).rstrip()

        logging.info("Firmware response: {}".format(self.firmware))
        # Check for valid firmware string
        if self.firmware:
            match = re.match(r"Sangaboard Firmware v(([\d]+)(?:\.([\d]+))+)", self.firmware)