'Parse a document from a file object, returning the document
node.'

def parseFile(self, file):

    parser = self.getParser()
    first_buffer = True
    try:
        while 1:
            buffer = file.read(16384)
            if (not buffer):
                break
            parser.Parse(buffer, 0)
            if (first_buffer and self.document.documentElement):
                self._setup_subset(buffer)
            first_buffer = False
        parser.Parse('', True)
    except ParseEscape:
        pass
    doc = self.document
    self.reset()
    self._parser = None
    return doc
