本文整理汇总了Python中xml.etree.ElementTree.VERSION属性的典型用法代码示例。如果您正苦于以下问题:Python ElementTree.VERSION属性的具体用法?Python ElementTree.VERSION怎么用?Python ElementTree.VERSION使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类xml.etree.ElementTree
的用法示例。
在下文中一共展示了ElementTree.VERSION属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from xml.etree import ElementTree [as 别名]
# 或者: from xml.etree.ElementTree import VERSION [as 别名]
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)
示例2: importETree
# 需要导入模块: from xml.etree import ElementTree [as 别名]
# 或者: from xml.etree.ElementTree import VERSION [as 别名]
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