diff --git a/gds/parser.py b/gds/parser.py index 1c50232..44abf53 100644 --- a/gds/parser.py +++ b/gds/parser.py @@ -29,19 +29,16 @@ class ParserError(Exception): pass class Parser(Reader): - # parser stack - _token = None - progress_callback = None - - # parser state - Library = Library() - current_structure = None - def __init__(self, file, progress_callback=None): super(Parser, self).__init__(file) - + + self._token = None self.progress_callback = progress_callback - + + # parser state + self.Library = Library() + self.current_structure = None + @property def token(self): return self._token diff --git a/gds/reader.py b/gds/reader.py index ff7a538..4c37e98 100644 --- a/gds/reader.py +++ b/gds/reader.py @@ -99,7 +99,9 @@ class Reader(ProgressGetter): return 0 def read_ascii(self, len): - return self.stream.read(len).decode("ASCII").strip() + # removes zero terminators + # as well as trailing and beginning whitespaces + return self.stream.read(len).decode("ASCII").replace("\x00", "").strip() def read_record(self): result = Record()