Python xml.etree.ElementTree.VERSION Examples
The following are 2
code examples of xml.etree.ElementTree.VERSION().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
xml.etree.ElementTree
, or try the search function
.
Example #1
Source File: config.py From terraform-templates with Apache License 2.0 | 5 votes |
def __init__(self, config=None, tags_forcelist=_tags_forcelist): self._log = logging.getLogger(__name__).log self._config_version = 0 # 0 indicates not yet set self._config_panorama = None self._config_multi_vsys = None self._log(DEBUG3, 'Python version: %s', sys.version) self._log(DEBUG3, 'xml.etree.ElementTree version: %s', etree.VERSION) self._log(DEBUG3, 'pan-python version: %s', __version__) if config is None: raise PanConfigError('no config') self._log(DEBUG2, '%s', type(config)) if hasattr(config, 'tag'): self.config_root = config else: try: self.config_root = etree.fromstring(config) except etree.ParseError as msg: raise PanConfigError('ElementTree.fromstring ParseError: %s' % msg) self._log(DEBUG1, 'config_root: %s', self.config_root)
Example #2
Source File: etree_loader.py From lambda-packs with MIT License | 5 votes |
def importETree(): """Import the best implementation of ElementTree, return a module object.""" etree_in_c = None try: # Is it Python 2.5+ with C implemenation of ElementTree installed? import xml.etree.cElementTree as etree_in_c from xml.etree.ElementTree import Comment except ImportError: try: # Is it Python 2.5+ with Python implementation of ElementTree? import xml.etree.ElementTree as etree except ImportError: try: # An earlier version of Python with cElementTree installed? import cElementTree as etree_in_c from elementtree.ElementTree import Comment except ImportError: try: # An earlier version of Python with Python ElementTree? import elementtree.ElementTree as etree except ImportError: raise ImportError("Failed to import ElementTree") if etree_in_c: if etree_in_c.VERSION < "1.0.5": raise RuntimeError("cElementTree version 1.0.5 or higher is required.") # Third party serializers (including ours) test with non-c Comment etree_in_c.test_comment = Comment return etree_in_c elif etree.VERSION < "1.1": raise RuntimeError("ElementTree version 1.1 or higher is required") else: return etree