1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
#!/usr/bin/env python3
"""Helper script used to remove the bundled examples from the DocBook files
that are used to generate the PDF documentation.
This file is part of the documentation build process. You do not need to call
it manually.
"""
import sys
from xml.etree.ElementTree import ElementTree
def usage():
print(sys.argv[0], "<infile> <outfile>")
def main():
if len(sys.argv) != 3:
usage()
sys.exit(2)
# Read in
tree = ElementTree()
tree.parse(sys.argv[1])
# Remove examples
examples = tree.findall(".//example")
for ex in examples:
prog = ex.find("programlisting")
ex.remove(prog)
# Write result
tree.write(sys.argv[2])
if __name__ == "__main__":
main()
|