def __init__(self, inputfile=None): """make a new QtTsParser, reading from the given inputfile if required""" self.filename = getattr(inputfile, "filename", None) self.knowncontextnodes = {} self.indexcontextnodes = {} if inputfile is None: self.document = ourdom.parseString("<!DOCTYPE TS><TS></TS>") else: self.document = ourdom.parse(inputfile) assert self.document.documentElement.tagName == "TS"