10f66f451Sopenharmony_ci#!/usr/bin/python 20f66f451Sopenharmony_ci 30f66f451Sopenharmony_ci# Create status.html 40f66f451Sopenharmony_ci 50f66f451Sopenharmony_ciimport subprocess,sys 60f66f451Sopenharmony_ci 70f66f451Sopenharmony_cidef readit(args, shell=False): 80f66f451Sopenharmony_ci ret={} 90f66f451Sopenharmony_ci arr=[] 100f66f451Sopenharmony_ci blob=subprocess.Popen(args, stdout=subprocess.PIPE, shell=shell) 110f66f451Sopenharmony_ci for i in blob.stdout.read().split("\n"): 120f66f451Sopenharmony_ci if not i: continue 130f66f451Sopenharmony_ci i=i.split() 140f66f451Sopenharmony_ci try: ret[i[0]].extend(i[1:]) 150f66f451Sopenharmony_ci except: ret[i[0]]=i[1:] 160f66f451Sopenharmony_ci arr.extend(i) 170f66f451Sopenharmony_ci return ret,arr 180f66f451Sopenharmony_ci 190f66f451Sopenharmony_ci# Run sed on roadmap and source to get command lists, and run toybox too 200f66f451Sopenharmony_ci# This gives us a dictionary of types, each with a list of commands 210f66f451Sopenharmony_ci 220f66f451Sopenharmony_ciprint "Collecting data..." 230f66f451Sopenharmony_ci 240f66f451Sopenharmony_cistuff,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"]) 250f66f451Sopenharmony_ciblah,toystuff=readit(["./toybox"]) 260f66f451Sopenharmony_ciblah,pending=readit(["sed -n 's/[^ \\t].*TOY(\\([^,]*\\),.*/\\1/p' toys/pending/*.c"], 1) 270f66f451Sopenharmony_ciblah,version=readit(["git","describe","--tags"]) 280f66f451Sopenharmony_ci 290f66f451Sopenharmony_ciprint "Analyzing..." 300f66f451Sopenharmony_ci 310f66f451Sopenharmony_ci# Create reverse mappings: reverse["command"] gives list of categories it's in 320f66f451Sopenharmony_ci 330f66f451Sopenharmony_cireverse={} 340f66f451Sopenharmony_cifor i in stuff: 350f66f451Sopenharmony_ci for j in stuff[i]: 360f66f451Sopenharmony_ci try: reverse[j].append(i) 370f66f451Sopenharmony_ci except: reverse[j]=[i] 380f66f451Sopenharmony_ciprint "all commands=%s" % len(reverse) 390f66f451Sopenharmony_ci 400f66f451Sopenharmony_ci# Run a couple sanity checks on input 410f66f451Sopenharmony_ci 420f66f451Sopenharmony_cifor i in toystuff: 430f66f451Sopenharmony_ci if (i in pending): print "barf %s" % i 440f66f451Sopenharmony_ci 450f66f451Sopenharmony_ciunknowns=[] 460f66f451Sopenharmony_cifor i in toystuff + pending: 470f66f451Sopenharmony_ci if not i in reverse: unknowns.append(i) 480f66f451Sopenharmony_ci 490f66f451Sopenharmony_ciif unknowns: print "uncategorized: %s" % " ".join(unknowns) 500f66f451Sopenharmony_ci 510f66f451Sopenharmony_ciconv = [("posix", '<a href="http://pubs.opengroup.org/onlinepubs/9699919799/utilities/%s.html">%%s</a>', "[%s]"), 520f66f451Sopenharmony_ci ("lsb", '<a href="http://refspecs.linuxfoundation.org/LSB_4.1.0/LSB-Core-generic/LSB-Core-generic/%s.html">%%s</a>', '<%s>'), 530f66f451Sopenharmony_ci ("development", '<a href="http://linux.die.net/man/1/%s">%%s</a>', '(%s)'), 540f66f451Sopenharmony_ci ("toolbox", "", '{%s}'), ("klibc_cmd", "", '=%s='), 550f66f451Sopenharmony_ci ("sash_cmd", "", '#%s#'), ("sbase_cmd", "", '@%s@'), 560f66f451Sopenharmony_ci ("beastiebox_cmd", "", '*%s*'), ("tizen", "", '$%s$'), 570f66f451Sopenharmony_ci ("shell", "", "%%%s%%"), 580f66f451Sopenharmony_ci ("request", '<a href="http://linux.die.net/man/1/%s">%%s</a>', '+%s+')] 590f66f451Sopenharmony_ci 600f66f451Sopenharmony_ci 610f66f451Sopenharmony_cidef categorize(reverse, i, skippy=""): 620f66f451Sopenharmony_ci linky = "%s" 630f66f451Sopenharmony_ci out = i 640f66f451Sopenharmony_ci 650f66f451Sopenharmony_ci if skippy: types = filter(lambda a: a != skippy, reverse[i]) 660f66f451Sopenharmony_ci else: types = reverse[i] 670f66f451Sopenharmony_ci 680f66f451Sopenharmony_ci for j in conv: 690f66f451Sopenharmony_ci if j[0] in types: 700f66f451Sopenharmony_ci if j[1]: linky = j[1] % i 710f66f451Sopenharmony_ci out = j[2] % out 720f66f451Sopenharmony_ci if not skippy: break 730f66f451Sopenharmony_ci if (not skippy) and out == i: 740f66f451Sopenharmony_ci sys.stderr.write("unknown %s %s\n" % (i,reverse[i])) 750f66f451Sopenharmony_ci 760f66f451Sopenharmony_ci return linky % out 770f66f451Sopenharmony_ci 780f66f451Sopenharmony_ci# Sort/annotate done, pending, and todo item lists 790f66f451Sopenharmony_ci 800f66f451Sopenharmony_ciallcmd=[] 810f66f451Sopenharmony_cidone=[] 820f66f451Sopenharmony_cipend=[] 830f66f451Sopenharmony_citodo=[] 840f66f451Sopenharmony_ciblah=list(reverse) 850f66f451Sopenharmony_ciblah.sort() 860f66f451Sopenharmony_cifor i in blah: 870f66f451Sopenharmony_ci out=categorize(reverse, i) 880f66f451Sopenharmony_ci allcmd.append(out) 890f66f451Sopenharmony_ci if i in toystuff or i in pending: 900f66f451Sopenharmony_ci if i in toystuff: done.append(out) 910f66f451Sopenharmony_ci else: pend.append(out) 920f66f451Sopenharmony_ci out='<strike>%s</strike>' % out 930f66f451Sopenharmony_ci else: todo.append(out) 940f66f451Sopenharmony_ci 950f66f451Sopenharmony_ciprint "implemented=%s" % len(toystuff) 960f66f451Sopenharmony_ci 970f66f451Sopenharmony_ci# Write data to output file 980f66f451Sopenharmony_ci 990f66f451Sopenharmony_cioutfile=open("www/status.gen", "w") 1000f66f451Sopenharmony_cioutfile.write("<h1>Status of toybox %s</h1>\n" % version[0]); 1010f66f451Sopenharmony_cioutfile.write("<h3>Legend: [posix] <lsb> (development) {android}\n") 1020f66f451Sopenharmony_cioutfile.write("=klibc= #sash# @sbase@ *beastiebox* $tizen$ %shell% +request+ other\n") 1030f66f451Sopenharmony_cioutfile.write("<strike>pending</strike></h3>\n"); 1040f66f451Sopenharmony_ci 1050f66f451Sopenharmony_cioutfile.write("<a name=done><h2><a href=#done>Completed</a></h2><blockquote><p>%s</p></blockquote>\n" % "\n".join(done)) 1060f66f451Sopenharmony_cioutfile.write("<a name=part><h2><a href=#part>Partially implemented</a></h2><blockquote><p>%s</p></blockquote>\n" % "\n".join(pend)) 1070f66f451Sopenharmony_cioutfile.write("<a name=todo><h2><a href=#todo>Not started yet</a></h2><blockquote><p>%s</p></blockquote>\n" % "\n".join(todo)) 1080f66f451Sopenharmony_ci 1090f66f451Sopenharmony_ci# Output unfinished commands by category 1100f66f451Sopenharmony_ci 1110f66f451Sopenharmony_cioutfile.write("<hr><h2>Categories of remaining todo items</h2>") 1120f66f451Sopenharmony_ci 1130f66f451Sopenharmony_cifor i in stuff: 1140f66f451Sopenharmony_ci todo = [] 1150f66f451Sopenharmony_ci 1160f66f451Sopenharmony_ci for j in stuff[i]: 1170f66f451Sopenharmony_ci if j in toystuff: continue 1180f66f451Sopenharmony_ci if j in pending: todo.append('<strike>%s</strike>' % j) 1190f66f451Sopenharmony_ci else: todo.append(categorize(reverse,j,i)) 1200f66f451Sopenharmony_ci 1210f66f451Sopenharmony_ci if todo: 1220f66f451Sopenharmony_ci k = i 1230f66f451Sopenharmony_ci for j in conv: 1240f66f451Sopenharmony_ci if j[0] == i: 1250f66f451Sopenharmony_ci k = j[2] % i 1260f66f451Sopenharmony_ci 1270f66f451Sopenharmony_ci outfile.write("<a name=%s><h2><a href=#%s>%s<a></h2><blockquote><p>" % (i,i,k)) 1280f66f451Sopenharmony_ci outfile.write(" ".join(todo)) 1290f66f451Sopenharmony_ci outfile.write("</p></blockquote>\n") 1300f66f451Sopenharmony_ci 1310f66f451Sopenharmony_cioutfile.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)) 132