summaryrefslogtreecommitdiff
path: root/docs-xml/scripts
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2012-09-26 02:05:39 +0200
committerJelmer Vernooij <jelmer@samba.org>2012-09-26 22:12:07 +0200
commitf2b2c1028bcb5da2292c543e4419d258ec3d6b46 (patch)
treee3ac7abb4beaada2fde5829eecefd89091addc59 /docs-xml/scripts
parent104c3df6cf759a69eafd303fe8d5870ae5d34149 (diff)
downloadsamba-f2b2c1028bcb5da2292c543e4419d258ec3d6b46.tar.gz
samba-f2b2c1028bcb5da2292c543e4419d258ec3d6b46.tar.bz2
samba-f2b2c1028bcb5da2292c543e4419d258ec3d6b46.zip
find_missing_manpages: convert to python
Diffstat (limited to 'docs-xml/scripts')
-rwxr-xr-xdocs-xml/scripts/find_missing_manpages74
1 files changed, 44 insertions, 30 deletions
diff --git a/docs-xml/scripts/find_missing_manpages b/docs-xml/scripts/find_missing_manpages
index 12cbc28555..a0a19af23f 100755
--- a/docs-xml/scripts/find_missing_manpages
+++ b/docs-xml/scripts/find_missing_manpages
@@ -1,40 +1,54 @@
-#!/usr/bin/perl
+#!/usr/bin/python
-my %doc;
+import optparse
+import os
+import re
-$invar = 0;
+parser = optparse.OptionParser("source_dir")
-$topdir = (shift @ARGV) or $topdir = ".";
+(opts, args) = parser.parse_args()
-$progs = "";
+invar = 0
-open(IN, "$topdir/Makefile.in");
-while(<IN>) {
- if($invar && /^([ \t]*)(.*?)([\\])$/) {
- $progs.=" " . $2;
- if($4) { $invar = 1; } else { $invar = 0; }
- } elsif(/^([^ ]*)_PROGS([0-9]*) = (.*?)([\\])$/) {
- $progs.=" " . $3;
- if($4) { $invar = 1; }
- } else { $invar = 0; }
-}
+if len(args) == 1:
+ topdir = args[0]
+else:
+ topdir = "."
-$progs =~ s/@([^@]+)@//g;
-$progs =~ s/\$\(.*?\)//g;
+progs = []
-foreach(split(/bin\//, $progs)) {
- next if($_ eq " ");
- s/ //g;
+f = open(os.path.join(topdir, "Makefile.in"), "r")
- $f = $_;
-
- $found = 0;
+for l in f.readlines():
+ l = l.strip()
+ if invar:
+ invar = (l[-1] == "\\")
+ progs.extend(l.rstrip("\\").split(" "))
+ else:
+ m = re.match("^([^ ]*)_PROGS([0-9]*) = (.*?)([\\\\])$", l)
+ if m:
+ progs.extend(m.group(3).split(" "))
+ invar = (m.group(4) == "\\")
+ else:
+ invar = False
- for($i = 0; $i < 9; $i++) {
- if(-e "manpages/$f.$i.xml") { $found = 1; }
- }
+#$progs =~ s/@([^@]+)@//g;
+#$progs =~ s/\$\(.*?\)//g;
- if(!$found) {
- print "'$f' does not have a manpage\n";
- }
-}
+for prog in progs:
+ prog = prog.strip()
+ if prog == "":
+ continue
+ if prog[0] in ("@", "$"):
+ continue
+ prog = prog[len("bin/"):]
+
+ found = False
+
+ for i in range(9):
+ p = "manpages/%s.%d.xml" % (prog, i)
+ if os.path.exists(p):
+ found = True
+
+ if not found:
+ print "'%s' does not have a manpage" % prog