本文整理匯總了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