6 class BadLdrawLine(Exception): |
6 class BadLdrawLine(Exception): |
7 pass |
7 pass |
8 |
8 |
9 def parse_ldraw_code(line): |
9 def parse_ldraw_code(line): |
10 if isinstance(line, bytes): |
10 if isinstance(line, bytes): |
11 line = line.decode() |
11 try: |
|
12 line = line.decode() |
|
13 except UnicodeDecodeError: |
|
14 raise BadLdrawLine("bad unicode") |
12 line = line.strip() |
15 line = line.strip() |
13 if not line: |
16 if not line: |
14 return linetypes.EmptyLine() |
17 return linetypes.EmptyLine() |
15 elif line == '0': |
18 elif line == '0': |
16 return linetypes.Comment('') |
19 return linetypes.Comment('') |