mkstatus.py 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. #!/usr/bin/python
  2. # Create status.html
  3. import subprocess,sys
  4. def readit(args, shell=False):
  5. ret={}
  6. arr=[]
  7. blob=subprocess.Popen(args, stdout=subprocess.PIPE, shell=shell)
  8. for i in blob.stdout.read().split("\n"):
  9. if not i: continue
  10. i=i.split()
  11. try: ret[i[0]].extend(i[1:])
  12. except: ret[i[0]]=i[1:]
  13. arr.extend(i)
  14. return ret,arr
  15. # Run sed on roadmap and source to get command lists, and run toybox too
  16. # This gives us a dictionary of types, each with a list of commands
  17. print "Collecting data..."
  18. 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"])
  19. blah,toystuff=readit(["./toybox"])
  20. blah,stuff["shell"]=readit(["sed", "-n", "s/.*NEWTOY[(]\\([^,]*\\).*TOYFLAG_NOFORK.*/\\1/p", "toys/pending/sh.c"])
  21. blah,pending=readit(["/bin/bash", "-c", "sed -n 's/[^ \\t].*TOY(\\([^,]*\\),.*/\\1/p' toys/pending/*.c"])
  22. version=readit(["./toybox","--version"])[-1][-1]
  23. print "Analyzing..."
  24. # Create reverse mappings: reverse["command"] gives list of categories it's in
  25. reverse={}
  26. for i in stuff:
  27. for j in stuff[i]:
  28. try: reverse[j].append(i)
  29. except: reverse[j]=[i]
  30. print "all commands=%s" % len(reverse)
  31. # Run a couple sanity checks on input
  32. for i in toystuff:
  33. if (i in pending): print "barf %s" % i
  34. unknowns=[]
  35. for i in toystuff + pending:
  36. if not i in reverse: unknowns.append(i)
  37. if unknowns: print "uncategorized: %s" % " ".join(unknowns)
  38. conv = [("posix", '<a href="http://pubs.opengroup.org/onlinepubs/9699919799/utilities/%s.html">%%s</a>', "[%s]"),
  39. ("lsb", '<a href="http://refspecs.linuxfoundation.org/LSB_4.1.0/LSB-Core-generic/LSB-Core-generic/%s.html">%%s</a>', '&lt;%s&gt;'),
  40. ("development", '<a href="https://man7.org/linux/man-pages/man1/%s.1.html">%%s</a>', '(%s)'),
  41. ("toolbox", "", '{%s}'), ("klibc_cmd", "", '=%s='),
  42. ("sash_cmd", "", '#%s#'), ("sbase_cmd", "", '@%s@'),
  43. ("beastiebox_cmd", "", '*%s*'), ("tizen_cmd", "", '$%s$'),
  44. ("fhs_cmd", "", '-%s-'), ("yocto_cmd", "", ".%s."),
  45. ("shell", "", "%%%s%%"),
  46. ("request", '<a href="https://man7.org/linux/man-pages/man1/%s.1.html">%%s</a>', '+%s+')]
  47. def categorize(reverse, i, skippy=""):
  48. linky = "%s"
  49. out = i
  50. if skippy: types = filter(lambda a: a != skippy, reverse[i])
  51. else: types = reverse[i]
  52. for j in conv:
  53. if j[0] in types:
  54. if j[1]: linky = j[1] % i
  55. out = j[2] % out
  56. if not skippy: break
  57. if (not skippy) and out == i:
  58. sys.stderr.write("unknown %s %s\n" % (i,reverse[i]))
  59. return linky % out
  60. # Sort/annotate done, pending, and todo item lists
  61. allcmd=[]
  62. done=[]
  63. pend=[]
  64. todo=[]
  65. blah=list(reverse)
  66. blah.sort()
  67. for i in blah:
  68. out=categorize(reverse, i)
  69. allcmd.append(out)
  70. if i in toystuff or i in pending:
  71. if i in toystuff: done.append(out)
  72. else: pend.append(out)
  73. out='<strike>%s</strike>' % out
  74. else: todo.append(out)
  75. print "implemented=%s" % len(toystuff)
  76. # Write data to output file
  77. outfile=open("www/status.html", "w")
  78. outfile.write("""<html><head><title>toybox current status</title>
  79. <!--#include file="header.html" -->
  80. <title>Toybox Status</title>
  81. """);
  82. outfile.write("<h1>Status of toybox %s</h1>\n" % version);
  83. outfile.write("<h3>Legend: %s <strike>pending</strike></h3>\n"%" ".join(map(lambda i: i[2]%(i[0].split("_")[0]), conv)))
  84. outfile.write("<a name=done><h2><a href=#done>Completed</a></h2><blockquote><p>%s</p></blockquote>\n" % "\n".join(done))
  85. outfile.write("<a name=part><h2><a href=#part>Partially implemented (in toys/pending)</a></h2><blockquote><p>%s</p></blockquote>\n" % "\n".join(pend))
  86. outfile.write("<a name=todo><h2><a href=#todo>Not started yet</a></h2><blockquote><p>%s</p></blockquote>\n" % "\n".join(todo))
  87. # Output unfinished commands by category
  88. outfile.write("<hr><h2>Categories of remaining todo items</h2>")
  89. for i in conv:
  90. todo = []
  91. i=i[0]
  92. for j in stuff[i]:
  93. if j in toystuff: continue
  94. if j in pending: todo.append('<strike>%s</strike>' % j)
  95. else: todo.append(categorize(reverse,j,i))
  96. if todo:
  97. k = i
  98. for j in conv:
  99. if j[0] == i:
  100. k = j[2] % i.split("_")[0]
  101. outfile.write("<a name=%s><h2><a href=#%s>%s<a></h2><blockquote><p>" % (i,i,k))
  102. outfile.write(" ".join(todo))
  103. outfile.write("</p></blockquote>\n")
  104. 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))
  105. outfile.write("""
  106. <p>See the <a href=roadmap.html>Roadmap page</a> for more information.</p>
  107. <!-- #include "footer.html" -->""")