10 print(f'usage: {argv[0]:s} scale')
11 sys.exit(EXIT_FAILURE)
12 scale = float(sys.argv[1])
14 re_scalar = re.compile('( *(cx|cy|dx|dy|r|stroke-width|x1|x2|y1|y2)=")([^"]*)(".*)')
15 re_scalar2 = re.compile('( *stdDeviation=")([^ "]*)( ([^ "]*))?(".*)')
16 re_viewbox = re.compile('( *viewBox="0 0 )([^ "]*) ([^ "]*)(".*)')
17 re_path = re.compile('( *d=")([^"]*)(".*)')
18 re_path_command = re.compile('([A-Za-z,]) *(.*)')
19 re_path_number = re.compile('(-?([0-9]*\.[0-9]+|[0-9]+)) *(.*)')
20 for line in sys.stdin:
21 match = re_scalar.match(line)
23 line = match.group(1) + str(float(match.group(3)) * scale) + match.group(4) + '\n'
25 match = re_scalar2.match(line)
27 out = [str(float(match.group(2)) * scale)]
28 if match.group(3) is not None:
29 out.append(str(float(match.group(4)) * scale))
30 line = match.group(1) + ' '.join(out) + match.group(5) + '\n'
32 match = re_viewbox.match(line)
34 line = match.group(1) + str(float(match.group(2)) * scale) + ' ' + str(float(match.group(3)) * scale) + match.group(4) + '\n'
36 match = re_path.match(line)
38 path = match.group(2).lstrip()
41 match2 = re_path_command.match(path)
42 if match2 is not None:
43 out.append(match2.group(1))
44 path = match2.group(2)
46 match2 = re_path_number.match(path)
47 if match2 is not None:
48 out.append(str(float(match2.group(1)) * scale))
49 path = match2.group(3)
53 line = match.group(1) + ' '.join(out).replace(' ,', ',').replace(', ', ',') + match.group(3) + '\n'
54 sys.stdout.write(line)