chiark / gitweb /
man: use lxml for faster generation and pretty printing
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 8 Mar 2013 01:13:40 +0000 (20:13 -0500)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sat, 9 Mar 2013 13:47:50 +0000 (08:47 -0500)
README
make-directive-index.py
make-man-index.py

diff --git a/README b/README
index 9d7a547..b8d1f42 100644 (file)
--- a/README
+++ b/README
@@ -116,6 +116,7 @@ REQUIREMENTS:
         gtkdocize (optional)
         python (optional)
         sphinx (optional)
+        python-lxml (entirely optional)
 
         When systemd-hostnamed is used it is strongly recommended to
         install nss-myhostname to ensure that in a world of
index c61383b..039efaa 100755 (executable)
 
 import sys
 import collections
-import xml.etree.ElementTree as tree
+try:
+    from lxml import etree as tree
+    PRETTY = dict(pretty_print=True)
+except ImportError:
+    import xml.etree.ElementTree as tree
+    PRETTY = {}
 import re
 
 TEMPLATE = '''\
@@ -277,4 +282,4 @@ def make_page(*xml_files):
     return _make_page(template, directive_groups, formatting)
 
 if __name__ == '__main__':
-    tree.dump(make_page(*sys.argv[1:]))
+    tree.dump(make_page(*sys.argv[1:]), **PRETTY)
index d38d5b6..d9ab5cc 100755 (executable)
 #  along with systemd; If not, see <http://www.gnu.org/licenses/>.
 
 import collections
-import xml.etree.ElementTree as tree
+try:
+    from lxml import etree as tree
+    PRETTY = dict(pretty_print=True)
+except ImportError:
+    import xml.etree.ElementTree as tree
+    PRETTY = {}
 import sys
 import re
 MDASH = ' — ' if sys.version_info.major >= 3 else ' -- '
@@ -130,4 +135,4 @@ def make_page(xml_files):
     return template
 
 if __name__ == '__main__':
-    tree.dump(make_page(sys.argv[1:]))
+    tree.dump(make_page(sys.argv[1:]), **PRETTY)