blender-gdsimporter/test.py

39 lines
1.0 KiB
Python
Raw Normal View History

import gds
import sys
import math
import progress.bar
global bar
def callback(parser):
global bar
bar.max = parser.total
bar.index = parser.current
bar.update()
for arg in sys.argv[1:]:
f = open(arg, "rb")
try:
bar = progress.bar.IncrementalBar("parsing file")
lib = gds.parse_file(f, progress_func=callback)
print()
print("file version: {}".format(lib.version))
print("last access: {}".format(lib.last_access.isoformat()))
print("last modification: {}".format(lib.last_mod.isoformat()))
print("m/unit : {}".format(lib.meters_per_unit))
print("unit/dbunit : {}".format(lib.units_per_dbunit))
print("library name : {}".format(lib.name))
print("contains a total of {} structure(s)".format(len(lib.structures)))
bar = progress.bar.IncrementalBar("linking structure references")
lib.link_srefs(callback)
except gds.ParserError as e:
print("parser error: {}".format(e))
finally:
f.close()