| 1 | import os,re
|
|---|
| 2 |
|
|---|
| 3 | sorting = lambda x: x[3][2] # by key
|
|---|
| 4 | #sorting = lambda x: x[3][3] # by group
|
|---|
| 5 |
|
|---|
| 6 | tab=[];
|
|---|
| 7 |
|
|---|
| 8 | def addToList(lst,v):
|
|---|
| 9 | v=v.replace("tr\"","")
|
|---|
| 10 | v=v.replace("\"","")
|
|---|
| 11 | v=v.replace("KeyEvent.","")
|
|---|
| 12 | v=v.replace("Shortcut.","")
|
|---|
| 13 | lst.append(v.strip())
|
|---|
| 14 |
|
|---|
| 15 | def check(a,b,plugFlag):
|
|---|
| 16 | global nm,tab
|
|---|
| 17 | try:
|
|---|
| 18 | f = open(a, "r",encoding='utf-8') #Opens the file in read-mode
|
|---|
| 19 | text = f.read() #Reads the file and assigns the value to a variable
|
|---|
| 20 | f.close()
|
|---|
| 21 | except:
|
|---|
| 22 | return
|
|---|
| 23 | ms=re.findall("\.registerShortcut[^\;]*\;",text,re.S+re.M)
|
|---|
| 24 | #print("\n",b)
|
|---|
| 25 | for s in ms:
|
|---|
| 26 | vs=[]
|
|---|
| 27 | m=re.search("\.registerShortcut([^\;]*)",s)
|
|---|
| 28 | q=m.groups(0)[0]
|
|---|
| 29 | v=""; n=0
|
|---|
| 30 | for c in q:
|
|---|
| 31 | if c=="(":
|
|---|
| 32 | n=n+1;
|
|---|
| 33 | elif c==")":
|
|---|
| 34 | n=n-1;
|
|---|
| 35 | if n==0:
|
|---|
| 36 | addToList(vs,v)
|
|---|
| 37 | elif c==",":
|
|---|
| 38 | if n==1:
|
|---|
| 39 | addToList(vs,v)
|
|---|
| 40 | v=""
|
|---|
| 41 | else:
|
|---|
| 42 | if c!="\n":
|
|---|
| 43 | v=v+c
|
|---|
| 44 | if n==0:
|
|---|
| 45 | break;
|
|---|
| 46 | # print("vs:",vs)
|
|---|
| 47 | if vs:
|
|---|
| 48 | tab.append((plugFlag,a,b,vs))
|
|---|
| 49 |
|
|---|
| 50 | def saveHtml():
|
|---|
| 51 | global sortColumn
|
|---|
| 52 | f2 = open("shortcuts.html","w",encoding='utf-8')
|
|---|
| 53 | f2.write("""<html><body>
|
|---|
| 54 | """)
|
|---|
| 55 |
|
|---|
| 56 | f2.write("""<head>
|
|---|
| 57 | <style type="text/css">
|
|---|
| 58 |
|
|---|
| 59 | table
|
|---|
| 60 | {
|
|---|
| 61 | color:#000;
|
|---|
| 62 | background: #DFD;
|
|---|
| 63 | border-collapse:collapse;
|
|---|
| 64 | width:647px;
|
|---|
| 65 | border:5px solid lightseagreen;
|
|---|
| 66 | }
|
|---|
| 67 |
|
|---|
| 68 | td
|
|---|
| 69 | {
|
|---|
| 70 | padding:.5em 1em;
|
|---|
| 71 | }
|
|---|
| 72 | tr:nth-child(even) {background: yellowgreen}
|
|---|
| 73 |
|
|---|
| 74 | tr.C { font-weight: bold }
|
|---|
| 75 |
|
|---|
| 76 | tfoot
|
|---|
| 77 | {
|
|---|
| 78 | }
|
|---|
| 79 | tfoot td
|
|---|
| 80 | {
|
|---|
| 81 | padding-bottom:1.5em;
|
|---|
| 82 | }
|
|---|
| 83 | </style>
|
|---|
| 84 |
|
|---|
| 85 | </head>""");
|
|---|
| 86 |
|
|---|
| 87 | f2.write("""<table>
|
|---|
| 88 | <thead>
|
|---|
| 89 | <th>N</th>
|
|---|
| 90 | <th>File</th>
|
|---|
| 91 | <th>name</th>
|
|---|
| 92 | <th>title</th>
|
|---|
| 93 | <th>key</th>
|
|---|
| 94 | <th>group</th>
|
|---|
| 95 | <th>mod</th>
|
|---|
| 96 | </thead><tboby>
|
|---|
| 97 | """)
|
|---|
| 98 | num=0
|
|---|
| 99 | tab.sort(key=sorting)
|
|---|
| 100 | for t in tab:
|
|---|
| 101 | num=num+1
|
|---|
| 102 | #print(t)
|
|---|
| 103 | f2.write("<tr class=\""+t[0]+"\">")
|
|---|
| 104 | f2.write("<td>%d</td>\n" % num);
|
|---|
| 105 | f2.write("<td><a href=\""+t[1]+"\">"+t[2]+"</a></td>\n")
|
|---|
| 106 | for td in t[3]:
|
|---|
| 107 | f2.write("<td>"+td+"</td>\n")
|
|---|
| 108 | f2.write("</tr>")
|
|---|
| 109 |
|
|---|
| 110 | f2.write("""
|
|---|
| 111 | </table></tboby>""")
|
|---|
| 112 |
|
|---|
| 113 | f2.write("""
|
|---|
| 114 | </body></html>""")
|
|---|
| 115 | f2.close()
|
|---|
| 116 |
|
|---|
| 117 |
|
|---|
| 118 | for root, dirs, names in os.walk("core/src"):
|
|---|
| 119 | for name in names:
|
|---|
| 120 | if re.match(".*\.java",name):
|
|---|
| 121 | full=os.path.join(root, name);
|
|---|
| 122 | check(full,name,'C');
|
|---|
| 123 | for root, dirs, names in os.walk("plugins"):
|
|---|
| 124 | for name in names:
|
|---|
| 125 | if re.match(".*\.java",name):
|
|---|
| 126 | plugName=re.search(r"plugins\\([^\\]*)\\",root)
|
|---|
| 127 | if plugName:
|
|---|
| 128 | pName=plugName.groups(0)[0]
|
|---|
| 129 | full=os.path.join(root, name);
|
|---|
| 130 | check(full,pName,'P');
|
|---|
| 131 | saveHtml()
|
|---|
| 132 |
|
|---|
| 133 |
|
|---|
| 134 |
|
|---|