Coverage for /home/martinb/.local/share/virtualenvs/camcops/lib/python3.6/site-packages/openpyxl/xml/__init__.py : 72%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1# Copyright (c) 2010-2020 openpyxl
4"""Collection of XML resources compatible across different Python versions"""
5import os
8def lxml_available():
9 try:
10 from lxml.etree import LXML_VERSION
11 LXML = LXML_VERSION >= (3, 3, 1, 0)
12 if not LXML:
13 import warnings
14 warnings.warn("The installed version of lxml is too old to be used with openpyxl")
15 return False # we have it, but too old
16 else:
17 return True # we have it, and recent enough
18 except ImportError:
19 return False # we don't even have it
22def lxml_env_set():
23 return os.environ.get("OPENPYXL_LXML", "True") == "True"
26LXML = lxml_available() and lxml_env_set()
29def defusedxml_available():
30 try:
31 import defusedxml # noqa
32 except ImportError:
33 return False
34 else:
35 return True
38def defusedxml_env_set():
39 return os.environ.get("OPENPYXL_DEFUSEDXML", "True") == "True"
42DEFUSEDXML = defusedxml_available() and defusedxml_env_set()