OSDN Git Service

am 7e612cb8: (-s ours) am f41c7e0b: Merge remote-tracking branch \'toybox/master...
[android-x86/external-toybox.git] / scripts / mkstatus.py
1 #!/usr/bin/python
2
3 # Create status.html
4
5 import subprocess,sys
6
7 def readit(args, shell=False):
8   ret={}
9   arr=[]
10   blob=subprocess.Popen(args, stdout=subprocess.PIPE, shell=shell)
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
17
18 # Run sed on roadmap and source to get command lists, and run toybox too
19 # This gives us a dictionary of types, each with a list of commands
20
21 print "Collecting data..."
22
23 stuff,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"])
24 blah,toystuff=readit(["./toybox"])
25 blah,pending=readit(["sed -n 's/[^ \\t].*TOY(\\([^,]*\\),.*/\\1/p' toys/pending/*.c"], 1)
26 blah,version=readit(["git","describe","--tags"])
27
28 print "Analyzing..."
29
30 # Create reverse mappings: reverse["command"] gives list of categories it's in
31
32 reverse={}
33 for i in stuff:
34   for j in stuff[i]:
35     try: reverse[j].append(i)
36     except: reverse[j]=[i]
37 print "all commands=%s" % len(reverse)
38
39 # Run a couple sanity checks on input
40
41 for i in toystuff:
42   if (i in pending): print "barf %s" % i
43
44 unknowns=[]
45 for i in toystuff + pending:
46   if not i in reverse: unknowns.append(i)
47
48 if unknowns: print "uncategorized: %s" % " ".join(unknowns)
49
50 conv = [("posix", '<a href="http://pubs.opengroup.org/onlinepubs/9699919799/utilities/%s.html">%%s</a>', "[%s]"),
51         ("lsb", '<a href="http://refspecs.linuxfoundation.org/LSB_4.1.0/LSB-Core-generic/LSB-Core-generic/%s.html">%%s</a>', '&lt;%s&gt;'),
52         ("development", '<a href="http://linux.die.net/man/1/%s">%%s</a>', '(%s)'),
53         ("toolbox", "", '{%s}'), ("klibc_cmd", "", '=%s='),
54         ("sash_cmd", "", '#%s#'), ("sbase_cmd", "", '@%s@'),
55         ("beastiebox_cmd", "", '*%s*'), ("tizen", "", '$%s$'),
56         ("request", '<a href="http://linux.die.net/man/1/%s">%%s</a>', '+%s+')]
57
58
59 def categorize(reverse, i, skippy=""):
60   linky = "%s"
61   out = i
62
63   if skippy: types = filter(lambda a: a != skippy, reverse[i])
64   else: types = reverse[i]
65
66   for j in conv:
67     if j[0] in types:
68       if j[1]: linky = j[1] % i
69       out = j[2] % out
70       if not skippy: break
71   if (not skippy) and out == i:
72     sys.stderr.write("unknown %s %s\n" % (i,reverse[i]))
73
74   return linky % out
75
76 # Sort/annotate done, pending, and todo item lists
77
78 allcmd=[]
79 done=[]
80 pend=[]
81 todo=[]
82 blah=list(reverse)
83 blah.sort()
84 for i in blah:
85   out=categorize(reverse, i)
86   allcmd.append(out)
87   if i in toystuff or i in pending:
88     if i in toystuff: done.append(out)
89     else: pend.append(out)
90     out='<strike>%s</strike>' % out
91   else: todo.append(out)
92
93 print "implemented=%s" % len(toystuff)
94
95 # Write data to output file
96
97 outfile=open("www/status.gen", "w")
98 outfile.write("<h1>Status of toybox %s</h1>\n" % version[0]);
99 outfile.write("<h3>Legend: [posix] &lt;lsb&gt; (development) {android}\n")
100 outfile.write("=klibc= #sash# @sbase@ *beastiebox* $tizen$ +request+ other\n")
101 outfile.write("<strike>pending</strike></h3>\n");
102
103 outfile.write("<a name=done><h2><a href=#done>Completed</a></h2><blockquote><p>%s</p></blockquote>\n" % "\n".join(done))
104 outfile.write("<a name=part><h2><a href=#part>Partially implemented</a></h2><blockquote><p>%s</p></blockquote>\n" % "\n".join(pend))
105 outfile.write("<a name=todo><h2><a href=#todo>Not started yet</a></h2><blockquote><p>%s</p></blockquote>\n" % "\n".join(todo))
106
107 # Output unfinished commands by category
108
109 outfile.write("<hr><h2>Categories of remaining todo items</h2>")
110
111 for i in stuff:
112   todo = []
113
114   for j in stuff[i]:
115     if j in toystuff: continue
116     if j in pending: todo.append('<strike>%s</strike>' % j)
117     else: todo.append(categorize(reverse,j,i))
118
119   if todo:
120     k = i
121     for j in conv:
122       if j[0] == i:
123         k = j[2] % i
124
125     outfile.write("<a name=%s><h2><a href=#%s>%s<a></h2><blockquote><p>" % (i,i,k))
126     outfile.write(" ".join(todo))
127     outfile.write("</p></blockquote>\n")
128
129 outfile.write("<hr><a name=all><h2><a href=#all>All commands together in one big list</a></h2><blockquote><p>%s</p></blockquote>\n" % "\n".join(allcmd))