2 from datetime import date
3 from os.path import dirname, isdir
4 from os import makedirs, system
11 makedirs(outdir, 0o755)
13 with open(sourcedir + "/conf.py") as cf:
17 def header(file, startdocname, command, description, authors, section):
25 :Manual section: {5:d}
29 '-' * len(description),
31 '-' * len(description),
32 date.today().isoformat(), release, section, project))
34 blankre = re.compile("^\s*$")
35 for page in man_pages:
36 outdirname = outdir + '/' + dirname(page[0])
37 if not isdir(outdirname):
38 makedirs(outdirname, 0o755)
39 filename = outdir + '/' + page[0] + '.rst'
40 outfile = open(filename, 'w')
41 infile = open(sourcedir + '/' + page[0] + '.rst', 'r')
43 # this is a crude hack. We look for the first blank line, and
44 # insert the rst2man header there.
46 # XXX consider really parsing input
49 lines = infile.readlines()
52 if (blankre.match(line)):
56 del lines[0:count + 1]
58 header(outfile, *page)
60 outfile.write("".join(lines))
63 system('set -x; rst2man {0} {1}/{2}.{3}'
64 .format(filename, outdir, page[0], page[4]))