small bugfixes

This commit is contained in:
Julian Daube 2019-07-02 14:45:15 +02:00
parent 167c40c9e5
commit 4eb3dc8407
3 changed files with 21 additions and 34 deletions

View File

@ -37,7 +37,6 @@ class Library(object):
count = Progress(self)
for key, value in self.structures.items():
for element in value.references:
if isinstance(element.structure, str):
# try to resolve link

View File

@ -122,6 +122,7 @@ class Parser(Reader):
def parse_structure(self):
self.structure = Structure()
print(self.structure.references)
if self.token.ident != Records.BGNSTR:
return False
@ -166,15 +167,17 @@ class Parser(Reader):
element.plex = self.read_int()
self.next_token(True)
def parse_boundary(self):
element = Boundary()
if not self.next_token():
def parse_layer(self, element):
if self.token.ident != Records.LAYER:
raise ParserError(errors.EXPECTED_LAYER)
self.parse_element(element)
element.layer = self.read_ushort()
if self.token.ident == Records.LAYER:
element.layer = self.read_short()
def parse_boundary(self):
element = Boundary()
self.next_token(True)
self.parse_element(element)
self.parse_layer(element)
if not self.next_token() or self.token.ident != Records.DATATYPE:
raise ParserError(errors.EXPECTED_DATATYPE)
@ -193,15 +196,9 @@ class Parser(Reader):
def parse_path(self):
element = Path()
if not self.next_token():
raise ParserError(errors.EXPECTED_LAYER)
self.next_token(True)
self.parse_element(element)
if self.token.ident != Records.LAYER:
raise ParserError(errors.EXPECTED_LAYER)
element.layer = self.read_short()
self.parse_layer(element)
if not self.next_token() or self.token.ident != Records.DATATYPE:
raise ParserError(errors.EXPECTED_DATATYPE)
@ -246,15 +243,9 @@ class Parser(Reader):
def parse_text(self):
element = Text()
if not self.next_token():
raise ParserError(errors.EXPECTED_LAYER)
self.next_token(True)
self.parse_element(element)
if not self.token.ident == Records.LAYER:
raise ParserError(errors.EXPECTED_LAYER)
element.layer = self.read_short()
self.parse_layer(element)
if not self.next_token() or self.token.ident != Records.TEXTTYPE:
raise ParserError(errors.EXPECTED_TEXTTYPE)
@ -299,11 +290,12 @@ class Parser(Reader):
self.structure.elements.append(element)
def parse_strans(self, trans:Transformation):
if self.token.ident != Records.STRANS:
return
flags = self.read_short()
flags = self.read_ushort()
if flags & 0x01:
trans.mirror_x = True
@ -325,15 +317,9 @@ class Parser(Reader):
def parse_box(self):
element = Box()
if not self.next_token():
raise ParserError(errors.EXPECTED_LAYER)
self.next_token(True)
self.parse_element(element)
if self.token.ident != Records.LAYER:
raise ParserError(errors.EXPECTED_LAYER)
element.layer = self.read_short()
self.parse_layer(element)
if not self.next_token() or self.token.ident != Records.BOXTYPE:
raise ParserError(errors.EXPECTED_BOXTYPE)
@ -393,6 +379,7 @@ class Parser(Reader):
element.structure = self.read_ascii(self.token.len)
self.next_token(True)
self.parse_strans(element.transformation)
if self.token.ident != Records.COLROW:

View File

@ -8,5 +8,6 @@ class Structure(object):
# contains all the low level elements
elements = []
# contains all sref and aref elements
references = []