ldraw.py

Sun, 10 Dec 2017 15:46:47 +0200

author
Santeri Piippo
date
Sun, 10 Dec 2017 15:46:47 +0200
changeset 2
50d3086070df
parent 1
5411a25cfca7
child 3
1dc58f44d556
permissions
-rwxr-xr-x

Moved the parsing function into a new file

0
55b4c97d44c5 Initial commit with half-done parsing function
Santeri Piippo
parents:
diff changeset
1 #!/usr/bin/env python3
2
50d3086070df Moved the parsing function into a new file
Santeri Piippo
parents: 1
diff changeset
2 from parse import parse_ldraw_code
0
55b4c97d44c5 Initial commit with half-done parsing function
Santeri Piippo
parents:
diff changeset
3
55b4c97d44c5 Initial commit with half-done parsing function
Santeri Piippo
parents:
diff changeset
4 def read_ldraw(file, *, libraries):
55b4c97d44c5 Initial commit with half-done parsing function
Santeri Piippo
parents:
diff changeset
5 result = list()
55b4c97d44c5 Initial commit with half-done parsing function
Santeri Piippo
parents:
diff changeset
6 for line in file:
55b4c97d44c5 Initial commit with half-done parsing function
Santeri Piippo
parents:
diff changeset
7 result.append(parse_ldraw_code(line))
55b4c97d44c5 Initial commit with half-done parsing function
Santeri Piippo
parents:
diff changeset
8 return result
55b4c97d44c5 Initial commit with half-done parsing function
Santeri Piippo
parents:
diff changeset
9
55b4c97d44c5 Initial commit with half-done parsing function
Santeri Piippo
parents:
diff changeset
10 if __name__ == '__main__':
55b4c97d44c5 Initial commit with half-done parsing function
Santeri Piippo
parents:
diff changeset
11 from sys import argv
55b4c97d44c5 Initial commit with half-done parsing function
Santeri Piippo
parents:
diff changeset
12 libraries = [{'path': '/home/teemu/ldraw', 'role': 'official'}]
55b4c97d44c5 Initial commit with half-done parsing function
Santeri Piippo
parents:
diff changeset
13 with open(argv[1], 'r') as file:
55b4c97d44c5 Initial commit with half-done parsing function
Santeri Piippo
parents:
diff changeset
14 model = read_ldraw(file, libraries = libraries)
55b4c97d44c5 Initial commit with half-done parsing function
Santeri Piippo
parents:
diff changeset
15 from pprint import pprint
55b4c97d44c5 Initial commit with half-done parsing function
Santeri Piippo
parents:
diff changeset
16 pprint(model)

mercurial