def parse_path(path):
    commands = set("MZLHVCSQTA")
    wsp = set(" \t\r\n")
    wsp_comma = wsp.union(set(","))
    signs = wsp.union(set("+-"))
    command = None
    arguments = []
    arg = ''
    for ch in path:
        if ch.upper() in commands:
            if arg:
                arguments.append(float(arg))
            if command:
                yield (command, tuple(arguments))
            command = ch
            arguments = []
            arg = ''
        elif ch in wsp_comma:
            if arg:
                arguments.append(float(arg))
            arg = ''
        elif ch in signs:
            if arg:
                arguments.append(float(arg))
            arg = ch
        else:
            arg += ch
dataset/ETHPy150Open vishnubob/silhouette/printsvg.py/parse_path/original