2019-07-01 11:45:02 +02:00
|
|
|
import gds
|
|
|
|
import sys
|
|
|
|
|
2019-07-01 13:09:01 +02:00
|
|
|
import math
|
|
|
|
import progress.bar
|
|
|
|
|
|
|
|
global bar
|
|
|
|
|
|
|
|
def callback(parser):
|
|
|
|
global bar
|
|
|
|
|
|
|
|
bar.max = parser.total
|
|
|
|
bar.index = parser.current
|
|
|
|
bar.update()
|
|
|
|
|
2019-07-01 11:45:02 +02:00
|
|
|
for arg in sys.argv[1:]:
|
|
|
|
f = open(arg, "rb")
|
|
|
|
try:
|
2019-07-01 13:09:01 +02:00
|
|
|
bar = progress.bar.IncrementalBar("parsing file")
|
|
|
|
lib = gds.parse_file(f, progress_func=callback)
|
|
|
|
print()
|
|
|
|
|
2019-07-01 11:45:02 +02:00
|
|
|
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)))
|
2019-07-02 19:38:33 +02:00
|
|
|
|
|
|
|
for name in lib.structures.keys():
|
|
|
|
#print(name, end = " ")
|
|
|
|
print("- {}".format(name))
|
|
|
|
for elem in lib.structures[name].elements:
|
|
|
|
if isinstance(elem, gds.Boundary):
|
|
|
|
for coord in elem.points:
|
|
|
|
coord = (coord[0] * lib.units_per_dbunit , coord[1] * lib.units_per_dbunit)
|
|
|
|
|
2019-07-01 13:09:01 +02:00
|
|
|
bar = progress.bar.IncrementalBar("linking structure references")
|
2019-07-02 19:38:33 +02:00
|
|
|
lib.link_refs(callback)
|
2019-07-01 11:45:02 +02:00
|
|
|
|
|
|
|
except gds.ParserError as e:
|
|
|
|
print("parser error: {}".format(e))
|
2019-07-02 19:38:33 +02:00
|
|
|
except KeyboardInterrupt:
|
|
|
|
continue
|
2019-07-01 11:45:02 +02:00
|
|
|
finally:
|
|
|
|
f.close()
|
2019-07-02 19:38:33 +02:00
|
|
|
|
|
|
|
print("\nall done")
|