parser: remove class elements; strip 0 from ascii strings
This commit is contained in:
parent
096715320b
commit
c1c8bc7a7d
@ -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
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user