- def from_file(cls, xmlfile, parse_dublincore=True, provider=None):
-
- # first, prepare for parsing
- if isinstance(xmlfile, basestring):
- file = open(xmlfile, 'rb')
- try:
- data = file.read()
- finally:
- file.close()
- else:
- data = xmlfile.read()
-
- if not isinstance(data, unicode):
- data = data.decode('utf-8')
-
- data = data.replace(u'\ufeff', '')
-
- try:
- parser = etree.XMLParser(remove_blank_text=False)
- tree = etree.parse(StringIO(data.encode('utf-8')), parser)
-
- return cls(tree, parse_dublincore=parse_dublincore, provider=provider)
- except (ExpatError, XMLSyntaxError, XSLTApplyError), e:
- raise ParseError(e)
+ def from_file(cls, xmlfile, *args, **kwargs):
+ iofile = IOFile.from_filename(xmlfile)
+ return cls(iofile, *args, **kwargs)