From e06d7dcd8fd96fcab97bd9781385e433b3a97221 Mon Sep 17 00:00:00 2001 From: _ <_> Date: Tue, 24 Apr 2018 21:51:11 -0700 Subject: [PATCH] Adjusted constructor to allow default 'blank' pld's --- bindings/py3devil1.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/bindings/py3devil1.py b/bindings/py3devil1.py index a3ed6d2..0e54412 100755 --- a/bindings/py3devil1.py +++ b/bindings/py3devil1.py @@ -239,12 +239,12 @@ devil1tex = Devil1TEX_FN.in_dll(libc, "DEVIL1TEX") devil1geo = Devil1GEO_FN.in_dll(libc, "DEVIL1GEO") class PLDHeader: - def __init__(self, filedata): - h = PldHeader() - devil1pld.getheader(ctypes.byref(h), filedata) + def __init__(self, filedata = None): self.offsets = [] - for i in range(0, h.numOffset): - self.offsets.append(h.offsets[i]) + if filedata: + h = PldHeader() + devil1pld.getheader(ctypes.byref(h), filedata) + self.offsets = h.offsets[:h.numOffset] def __str__(self): output = "numOffset: %s" % str(len(self.offsets)) @@ -313,6 +313,8 @@ if __name__ == "__main__": data = f.read() pld = PLDHeader(data) print(pld) + pld2 = PLDHeader() + print(pld2) #---------------------------------------+ # main() mainx()