since some distros strip xml out of python we should treat it as (#35538)

an optional dep
This commit is contained in:
Thomas S Hatch 2016-08-17 16:07:01 -06:00 committed by Nicole Thomas
parent e2bd575461
commit 5cbd5eb10f

View File

@ -14,6 +14,7 @@ import subprocess
from salt.ext.six import binary_type, string_types, text_type
from salt.ext.six.moves import cStringIO, StringIO
HAS_XML = True
try:
# Python >2.5
import xml.etree.cElementTree as ElementTree
@ -30,7 +31,8 @@ except Exception:
# normal ElementTree install
import elementtree.ElementTree as ElementTree
except Exception:
raise
ElementTree = None
HAS_XML = False
# True if we are running on Python 3.
@ -44,14 +46,15 @@ else:
import exceptions
if not hasattr(ElementTree, 'ParseError'):
class ParseError(Exception):
'''
older versions of ElementTree do not have ParseError
'''
pass
if HAS_XML:
if not hasattr(ElementTree, 'ParseError'):
class ParseError(Exception):
'''
older versions of ElementTree do not have ParseError
'''
pass
ElementTree.ParseError = ParseError
ElementTree.ParseError = ParseError
def text_(s, encoding='latin-1', errors='strict'):