blob: 82592c71a0d299b0306af847f5194fd49d14345a [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:
Rob Landley3c994042015-01-01 17:37:57 -060034 if ("ready" in reverse[i]) and ("pending" in reverse[i]): print "barf", i
35 except: pass
36 try:
Rob Landley7a78d922012-12-23 00:37:42 -060037 if ("ready" in reverse[i]) or ("pending" in reverse[i]): continue
38 except: pass
Rob Landley3c994042015-01-01 17:37:57 -060039 print "Not ready or pending:", i
Rob Landley37aa8212012-07-21 00:29:27 -050040
41pending=[]
42done=[]
43
Rob Landley9a69a922013-02-23 18:32:08 -060044print "all commands=%s" % len(reverse)
45
Rob Landley37aa8212012-07-21 00:29:27 -050046outfile=open("www/status.gen", "w")
Rob Landleye0cc81e2012-12-01 18:27:37 -060047outfile.write("<a name=all><h2><a href=#all>All commands</a></h2><blockquote><p>\n")
Rob Landley37aa8212012-07-21 00:29:27 -050048
Rob Landleyc166faf2013-09-01 07:25:37 -050049conv = [("posix", '<a href="http://pubs.opengroup.org/onlinepubs/9699919799/utilities/%s.html">%%s</a>', "[%s]"),
50 ("lsb", '<a href="http://refspecs.linuxfoundation.org/LSB_4.1.0/LSB-Core-generic/LSB-Core-generic/%s.html">%%s</a>', '&lt;%s&gt;'),
51 ("development", '<a href="http://linux.die.net/man/1/%s">%%s</a>', '(%s)'),
52 ("toolbox", "", '{%s}'), ("klibc_cmd", "", '=%s='),
53 ("sash_cmd", "", '#%s#'), ("sbase_cmd", "", '@%s@'),
Rob Landley3c994042015-01-01 17:37:57 -060054 ("beastiebox_cmd", "", '*%s*'), ("tizen", "", '$%s$'),
Rob Landleyc166faf2013-09-01 07:25:37 -050055 ("request", '<a href="http://linux.die.net/man/1/%s">%%s</a>', '+%s+')]
56
57
58def categorize(reverse, i, skippy=""):
59 linky = "%s"
60 out = i
61
62 if skippy: types = filter(lambda a: a != skippy, reverse[i])
63 else: types = reverse[i]
64
65 for j in conv:
66 if j[0] in types:
67 if j[1]: linky = j[1] % i
68 out = j[2] % out
69 if not skippy: break
70 if (not skippy) and out == i:
71 sys.stderr.write("unknown %s %s\n" % (i,reverse[i]))
72
73 return linky % out
74
Rob Landley37aa8212012-07-21 00:29:27 -050075blah=list(reverse)
76blah.sort()
77for i in blah:
Rob Landleyc166faf2013-09-01 07:25:37 -050078 out=categorize(reverse, i)
Rob Landley37aa8212012-07-21 00:29:27 -050079 if "ready" in reverse[i] or "pending" in reverse[i]:
Rob Landley37aa8212012-07-21 00:29:27 -050080 done.append(out)
Rob Landley8f90d3a2012-07-21 23:58:40 -050081 out='<strike>%s</strike>' % out
Rob Landley37aa8212012-07-21 00:29:27 -050082 else: pending.append(out)
83
84 outfile.write(out+"\n")
85
Rob Landley9a69a922013-02-23 18:32:08 -060086print "done=%s" % len(done)
Rob Landley37aa8212012-07-21 00:29:27 -050087outfile.write("</p></blockquote>\n")
88
Rob Landleye0cc81e2012-12-01 18:27:37 -060089outfile.write("<a name=todo><h2><a href=#todo>TODO</a></h2><blockquote><p>%s</p></blockquote>\n" % "\n".join(pending))
90outfile.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 -050091
92outfile.write("<hr><h2>Categories of remaining todo items</h2>")
93
94for i in stuff:
95 todo = []
96
97 for j in stuff[i]:
98 if "ready" in reverse[j]: continue
Rob Landley7dbb9822014-02-21 22:24:02 -060099 elif "pending" in reverse[j]: todo.append('<strike>%s</strike>' % j)
Rob Landleyc166faf2013-09-01 07:25:37 -0500100 else: todo.append(categorize(reverse,j,i))
101
102 if todo:
103 k = i
104 for j in conv:
105 if j[0] == i:
106 k = j[2] % i
107
108 outfile.write("<a name=%s><h2><a href=#%s>%s<a></h2><blockquote><p>" % (i,i,k))
109 outfile.write(" ".join(todo))
110 outfile.write("</p></blockquote>\n")