test: add progress bar to read operation

This commit is contained in:
Julian Daube 2019-07-01 13:09:01 +02:00
parent 06bc11fb17
commit 76f0677296

20
test.py
View File

@ -1,10 +1,25 @@
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:
lib = gds.parse_file(f)
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()))
@ -13,6 +28,9 @@ for arg in sys.argv[1:]:
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))