chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add pam configuration to allow user sessions to work out of the box
[elogind.git]
/
make-man-index.py
diff --git
a/make-man-index.py
b/make-man-index.py
index f829d98b6a587989ac9a0589354c436bf4347793..74a47b821a9538d4e8531fc123ac05edb934a170 100755
(executable)
--- a/
make-man-index.py
+++ b/
make-man-index.py
@@
-19,8
+19,10
@@
# along with systemd; If not, see <http://www.gnu.org/licenses/>.
import collections
# along with systemd; If not, see <http://www.gnu.org/licenses/>.
import collections
-import xml.etree.ElementTree as tree
import sys
import sys
+import re
+from xml_helper import *
+
MDASH = ' — ' if sys.version_info.major >= 3 else ' -- '
TEMPLATE = '''\
MDASH = ' — ' if sys.version_info.major >= 3 else ' -- '
TEMPLATE = '''\
@@
-66,10
+68,17
@@
SUMMARY = '''\
COUNTS = '\
This index contains {count} entries, referring to {pages} individual manual pages.'
COUNTS = '\
This index contains {count} entries, referring to {pages} individual manual pages.'
+
+def check_id(page, t):
+ id = t.getroot().get('id')
+ if not re.search('/' + id + '[.]', page):
+ raise ValueError("id='{}' is not the same as page name '{}'".format(id, page))
+
def make_index(pages):
index = collections.defaultdict(list)
for p in pages:
def make_index(pages):
index = collections.defaultdict(list)
for p in pages:
- t = tree.parse(p)
+ t = xml_parse(p)
+ check_id(p, t)
section = t.find('./refmeta/manvolnum').text
refname = t.find('./refnamediv/refname').text
purpose = ' '.join(t.find('./refnamediv/refpurpose').text.split())
section = t.find('./refmeta/manvolnum').text
refname = t.find('./refnamediv/refname').text
purpose = ' '.join(t.find('./refnamediv/refpurpose').text.split())
@@
-111,7
+120,7
@@
def add_summary(template, indexpages):
para = template.find(".//para[@id='counts']")
para.text = COUNTS.format(count=count, pages=len(pages))
para = template.find(".//para[@id='counts']")
para.text = COUNTS.format(count=count, pages=len(pages))
-def make_page(xml_files):
+def make_page(
*
xml_files):
template = tree.fromstring(TEMPLATE)
index = make_index(xml_files)
template = tree.fromstring(TEMPLATE)
index = make_index(xml_files)
@@
-123,4
+132,5
@@
def make_page(xml_files):
return template
if __name__ == '__main__':
return template
if __name__ == '__main__':
- tree.dump(make_page(sys.argv[1:]))
+ with open(sys.argv[1], 'wb') as f:
+ f.write(xml_print(make_page(*sys.argv[2:])))