summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/xml_helper.py22
1 files changed, 13 insertions, 9 deletions
diff --git a/tools/xml_helper.py b/tools/xml_helper.py
index 08e226fa21..0d91a17bbc 100644
--- a/tools/xml_helper.py
+++ b/tools/xml_helper.py
@@ -17,19 +17,23 @@
# You should have received a copy of the GNU Lesser General Public License
# along with systemd; If not, see <http://www.gnu.org/licenses/>.
-try:
- from lxml import etree as tree
+from lxml import etree as tree
- class CustomResolver(tree.Resolver):
- def resolve(self, url, id, context):
- if 'custom-entities.ent' in url:
- return self.resolve_filename('man/custom-entities.ent', context)
+class CustomResolver(tree.Resolver):
+ def resolve(self, url, id, context):
+ if 'custom-entities.ent' in url:
+ return self.resolve_filename('man/custom-entities.ent', context)
+try:
_parser = tree.XMLParser()
_parser.resolvers.add(CustomResolver())
- xml_parse = lambda page: tree.parse(page, _parser)
- xml_print = lambda xml: tree.tostring(xml, pretty_print=True,
- encoding='utf-8')
+ def xml_parse(page):
+ doc = tree.parse(page, _parser)
+ doc.xinclude()
+ return doc
+ def xml_print(xml):
+ return tree.tostring(xml, pretty_print=True, encoding='utf-8')
+
except ImportError:
import xml.etree.ElementTree as tree
import re as _re