Allow the HTML module to use the lxml HTML parser when parsing html file includes

This commit is contained in:
Calen Pennington
2012-07-03 13:18:01 -04:00
parent 92ea15b786
commit 67a732a0ff
2 changed files with 17 additions and 1 deletions

View File

@@ -90,6 +90,16 @@ class XmlDescriptor(XModuleDescriptor):
if xml_object.get(attr) is not None:
del xml_object.attrib[attr]
@classmethod
def file_to_xml(cls, file_object):
"""
Used when this module wants to parse a file object to xml
that will be converted to the definition.
Returns an lxml Element
"""
return etree.parse(file_object).getroot()
@classmethod
def from_xml(cls, xml_data, system, org=None, course=None):
"""
@@ -127,7 +137,7 @@ class XmlDescriptor(XModuleDescriptor):
filepath = cls._format_filepath(xml_object.tag, filename)
with system.resources_fs.open(filepath) as file:
try:
definition_xml = etree.parse(file).getroot()
definition_xml = cls.file_to_xml(file)
except:
log.exception("Failed to parse xml in file %s" % filepath)
raise