]> git.ipfire.org Git - thirdparty/systemd.git/blob - tools/xml_helper.py
tree-wide: drop license boilerplate
[thirdparty/systemd.git] / tools / xml_helper.py
1 #!/usr/bin/env python3
2 # -*- Mode: python; coding: utf-8; indent-tabs-mode: nil -*- */
3 # SPDX-License-Identifier: LGPL-2.1+
4 #
5 # This file is part of systemd.
6 #
7 # Copyright 2012-2013 Zbigniew Jędrzejewski-Szmek
8
9 from lxml import etree as tree
10
11 class CustomResolver(tree.Resolver):
12 def resolve(self, url, id, context):
13 if 'custom-entities.ent' in url:
14 return self.resolve_filename('man/custom-entities.ent', context)
15
16 _parser = tree.XMLParser()
17 _parser.resolvers.add(CustomResolver())
18
19 def xml_parse(page):
20 doc = tree.parse(page, _parser)
21 doc.xinclude()
22 return doc
23
24 def xml_print(xml):
25 return tree.tostring(xml, pretty_print=True, encoding='utf-8')