--- a/hpgl_parser.py Fri Dec 21 23:51:36 2007 +0100 +++ b/hpgl_parser.py Thu Jan 03 19:06:48 2008 +0100 @@ -7,13 +7,16 @@ vextractor = re.compile('(?P<value>[^;\n\r\aA-DF-Za-df-z]*?)(?P<terminator>[;\n\r\a]+)', re.S+re.M) class HPGLParser(object): - def __init__(self, data): + def __init__(self, data=None): + self.str_terminator = chr(0x03) + self.IN() + if data: + self.parse(data) + + def parse(self, data): self.data = data self.idx = 0 - self.str_terminator = chr(0x03) - - self.IN() - + self.IN() while self.idx<len(data): while data[self.idx] in [';','\n','\r', '\a', ' ']: self.idx += 1