update (tests not passing in python2, need to investigate)
parent
e71d2d4282
commit
05408cfa26
|
@ -37,8 +37,8 @@ A Big Problem:
|
||||||
from __future__ import division, absolute_import, print_function
|
from __future__ import division, absolute_import, print_function
|
||||||
import os
|
import os
|
||||||
import collections
|
import collections
|
||||||
import xml.etree.ElementTree as etree
|
from defusedxml.cElementTree import parse, tostring
|
||||||
from xml.etree.ElementTree import Element, SubElement, register_namespace
|
from xml.etree.cElementTree import Element, SubElement, register_namespace
|
||||||
from defusedxml.minidom import parseString
|
from defusedxml.minidom import parseString
|
||||||
import warnings
|
import warnings
|
||||||
from tempfile import gettempdir
|
from tempfile import gettempdir
|
||||||
|
@ -244,10 +244,10 @@ class Document:
|
||||||
self.original_filepath = os.path.join(os.getcwd(), filepath)
|
self.original_filepath = os.path.join(os.getcwd(), filepath)
|
||||||
|
|
||||||
if filepath is None:
|
if filepath is None:
|
||||||
self.tree = etree.ElementTree(Element('svg'))
|
self.tree = ElementTree(Element('svg'))
|
||||||
else:
|
else:
|
||||||
# parse svg to ElementTree object
|
# parse svg to ElementTree object
|
||||||
self.tree = etree.parse(filepath)
|
self.tree = parse(filepath)
|
||||||
|
|
||||||
self.root = self.tree.getroot()
|
self.root = self.tree.getroot()
|
||||||
|
|
||||||
|
@ -416,7 +416,7 @@ class Document:
|
||||||
SVG_NAMESPACE['svg']), group_attribs)
|
SVG_NAMESPACE['svg']), group_attribs)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return etree.tostring(self.tree.getroot()).decode()
|
return tostring(self.tree.getroot()).decode()
|
||||||
|
|
||||||
def pretty(self, **kwargs):
|
def pretty(self, **kwargs):
|
||||||
return parseString(repr(self)).toprettyxml(**kwargs)
|
return parseString(repr(self)).toprettyxml(**kwargs)
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
# External dependencies
|
# External dependencies
|
||||||
from __future__ import division, absolute_import, print_function
|
from __future__ import division, absolute_import, print_function
|
||||||
import os
|
import os
|
||||||
from xml.etree.ElementTree import Element, ElementTree, SubElement
|
from xml.etree.cElementTree import Element, ElementTree, SubElement
|
||||||
from defusedxml.cElementTree import iterparse
|
from defusedxml.cElementTree import iterparse
|
||||||
|
|
||||||
# Internal dependencies
|
# Internal dependencies
|
||||||
|
|
Loading…
Reference in New Issue