blob: cb34d457e1879abe12f103088f36b9c9d8ff1ab9 [file] [log] [blame]
Rob Landley37aa8212012-07-21 00:29:27 -05001#!/usr/bin/python
2
Rob Landley9a69a922013-02-23 18:32:08 -06003# Create status.html
4
Rob Landley37aa8212012-07-21 00:29:27 -05005import subprocess,sys
6
Rob Landley7a78d922012-12-23 00:37:42 -06007def readit(args):
8 ret={}
9 arr=[]
10 blob=subprocess.Popen(args, stdout=subprocess.PIPE, shell=False)
11 for i in blob.stdout.read().split("\n"):
12 if not i: continue
13 i=i.split()
14 ret[i[0]]=i[1:]
15 arr.extend(i)
16 return ret,arr
Rob Landley37aa8212012-07-21 00:29:27 -050017
Rob Landleyc166faf2013-09-01 07:25:37 -050018# Run sed on roadmap and status pages to get command lists, and run toybox too
19# This gives us a dictionary of types, each with a list of commands
Rob Landley7a78d922012-12-23 00:37:42 -060020
Rob Landleyc166faf2013-09-01 07:25:37 -050021stuff,blah=readit(["sed","-n", 's/<span id=\\([a-z_]*\\)>/\\1 /;t good;d;:good;h;:loop;n;s@</span>@@;t out;H;b loop;:out;g;s/\\n/ /g;p', "www/roadmap.html", "www/status.html"])
Rob Landley7a78d922012-12-23 00:37:42 -060022blah,toystuff=readit(["./toybox"])
Rob Landley8f90d3a2012-07-21 23:58:40 -050023
Rob Landleyc166faf2013-09-01 07:25:37 -050024# Create reverse mappings: command is in which
25
Rob Landley37aa8212012-07-21 00:29:27 -050026reverse={}
27for i in stuff:
28 for j in stuff[i]:
Rob Landley7a78d922012-12-23 00:37:42 -060029 try: reverse[j].append(i)
30 except: reverse[j]=[i]
31
32for i in toystuff:
33 try:
34 if ("ready" in reverse[i]) or ("pending" in reverse[i]): continue
35 except: pass
36 print i
Rob Landley37aa8212012-07-21 00:29:27 -050037
38pending=[]
39done=[]
40
Rob Landley9a69a922013-02-23 18:32:08 -060041print "all commands=%s" % len(reverse)
42
Rob Landley37aa8212012-07-21 00:29:27 -050043outfile=open("www/status.gen", "w")
Rob Landleye0cc81e2012-12-01 18:27:37 -060044outfile.write("<a name=all><h2><a href=#all>All commands</a></h2><blockquote><p>\n")
Rob Landley37aa8212012-07-21 00:29:27 -050045
Rob Landleyc166faf2013-09-01 07:25:37 -050046conv = [("posix", '<a href="http://pubs.opengroup.org/onlinepubs/9699919799/utilities/%s.html">%%s</a>', "[%s]"),
47 ("lsb", '<a href="http://refspecs.linuxfoundation.org/LSB_4.1.0/LSB-Core-generic/LSB-Core-generic/%s.html">%%s</a>', '&lt;%s&gt;'),
48 ("development", '<a href="http://linux.die.net/man/1/%s">%%s</a>', '(%s)'),
49 ("toolbox", "", '{%s}'), ("klibc_cmd", "", '=%s='),
50 ("sash_cmd", "", '#%s#'), ("sbase_cmd", "", '@%s@'),
51 ("beastiebox_cmd", "", '*%s*'),
52 ("request", '<a href="http://linux.die.net/man/1/%s">%%s</a>', '+%s+')]
53
54
55def categorize(reverse, i, skippy=""):
56 linky = "%s"
57 out = i
58
59 if skippy: types = filter(lambda a: a != skippy, reverse[i])
60 else: types = reverse[i]
61
62 for j in conv:
63 if j[0] in types:
64 if j[1]: linky = j[1] % i
65 out = j[2] % out
66 if not skippy: break
67 if (not skippy) and out == i:
68 sys.stderr.write("unknown %s %s\n" % (i,reverse[i]))
69
70 return linky % out
71
Rob Landley37aa8212012-07-21 00:29:27 -050072blah=list(reverse)
73blah.sort()
74for i in blah:
Rob Landleyc166faf2013-09-01 07:25:37 -050075 out=categorize(reverse, i)
Rob Landley37aa8212012-07-21 00:29:27 -050076 if "ready" in reverse[i] or "pending" in reverse[i]:
Rob Landley37aa8212012-07-21 00:29:27 -050077 done.append(out)
Rob Landley8f90d3a2012-07-21 23:58:40 -050078 out='<strike>%s</strike>' % out
Rob Landley37aa8212012-07-21 00:29:27 -050079 else: pending.append(out)
80
81 outfile.write(out+"\n")
82
Rob Landley9a69a922013-02-23 18:32:08 -060083print "done=%s" % len(done)
Rob Landley37aa8212012-07-21 00:29:27 -050084outfile.write("</p></blockquote>\n")
85
Rob Landleye0cc81e2012-12-01 18:27:37 -060086outfile.write("<a name=todo><h2><a href=#todo>TODO</a></h2><blockquote><p>%s</p></blockquote>\n" % "\n".join(pending))
87outfile.write("<a name=done><h2><a href=#done>Done</a></h2><blockquote><p>%s</p></blockquote>\n" % "\n".join(done))
Rob Landleyc166faf2013-09-01 07:25:37 -050088
89outfile.write("<hr><h2>Categories of remaining todo items</h2>")
90
91for i in stuff:
92 todo = []
93
94 for j in stuff[i]:
95 if "ready" in reverse[j]: continue
96 else: todo.append(categorize(reverse,j,i))
97
98 if todo:
99 k = i
100 for j in conv:
101 if j[0] == i:
102 k = j[2] % i
103
104 outfile.write("<a name=%s><h2><a href=#%s>%s<a></h2><blockquote><p>" % (i,i,k))
105 outfile.write(" ".join(todo))
106 outfile.write("</p></blockquote>\n")