Skip to content

Commit 8cc2542

Browse files
committed
fixes. works on whole of sketchnet
1 parent 85a1d7c commit 8cc2542

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

readSketchnet.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@
1919

2020
#parses a file to produce a big list of all the path data
2121
def fileToData(filename):
22-
num=r"(\d+(\.\d+)?)"
23-
straight="M{0} {0} L{0} {0} ".format(num)
24-
curve = "M{0} {0} (C{0} {0} {0} {0} {0} {0} )+".format(num)
25-
curvepiece = "C{0} {0} {0} {0} {0} {0} ".format(num)
22+
num=r"(-?\d+(\.\d+)?)"
23+
straight="M{0}[, ]{0} ?L{0}[, ]{0} ?".format(num)
24+
curve = "M{0}[, ]{0} ?(C{0}[, ]{0} {0}[, ]{0} {0}[, ]{0} ?)+".format(num)
25+
#note that curvepiece ends with a greedy +, we are relying on this working
26+
curvepiece = "C{0}[, ]{0} {0}[, ]{0} {0}[, ]{0}".format(num)
2627

2728
r = ET.parse(filename)
2829
g = r.find("i:g",ns).find("i:g",ns)
@@ -50,7 +51,7 @@ def fileToData(filename):
5051
#print (text,"\n", startpt,curvedata)
5152
out.append(("C",startpt,curvedata)) #C just for convenience
5253
else:
53-
raise RuntimeError("Unexpected path string: "+text)
54+
raise RuntimeError("Unexpected path string: '"+text+"'")
5455
return out
5556

5657

0 commit comments

Comments
 (0)