"""
XML utils
"""

from __future__ import print_function

import lxml.etree as ET
from lxml.builder import ElementMaker


#noinspection PyUnresolvedReferences
def output_xml(xml, filename):
    ET.ElementTree(xml).write(filename, encoding='utf-8', xml_declaration=True, pretty_print=True)


# create factory object
E = ElementMaker()

@@ -51,16 +51,25 @@
 nction%0A%0A
+try:%0A    
 import l
@@ -88,85 +88,13 @@
  ET%0A
-from lxml.builder import ElementMaker%0A%0A%0A#noinspection PyUnresolvedReferences%0A
+%0A    
 def 
@@ -120,16 +120,20 @@
 ename):%0A
+    
     ET.E
@@ -227,49 +227,230 @@
 ue)%0A
-%0A%0A# create factory object%0AE = ElementMaker(
+except ImportError:%0A    #noinspection PyRedeclaration%0A    import xml.etree.cElementTree as ET%0A%0A    #noinspection PyRedeclaration%0A    def output_xml(xml, filename):%0A        ET.ElementTree(xml).write(filename, encoding='utf-8'
 )%0A

add back ElementTree fallback for xml export