forked from ScoDoc/ScoDoc
Enhance API inspection tools
This commit is contained in:
parent
e61a9752d3
commit
64f74800ee
@ -5,10 +5,12 @@
|
|||||||
Quick method: just grep method name in all constant strings from the source code base.
|
Quick method: just grep method name in all constant strings from the source code base.
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
check_zope_usage.py methods-list.txt string-constants.txt
|
check_zope_usage.py publishedmethods.csv string-constants.txt
|
||||||
|
|
||||||
methods-list.txt : fichier texte, module et un nom de méthode / ligne
|
publishedmethods.csv : fichier texte, module et un nom de méthode / ligne
|
||||||
ZScoUsers get_userlist
|
ZScoUsers get_userlist
|
||||||
|
comme extrait par zopelistmethods.py
|
||||||
|
|
||||||
string-constants.txt : les constantes chaines, extraites par extract_code_strings.py
|
string-constants.txt : les constantes chaines, extraites par extract_code_strings.py
|
||||||
"scolars.py" "</li><li>"
|
"scolars.py" "</li><li>"
|
||||||
|
|
||||||
@ -17,12 +19,14 @@ E. Viennet 2021-01-09
|
|||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
import glob
|
||||||
|
|
||||||
methods_filename = sys.argv[1]
|
methods_filename = sys.argv[1]
|
||||||
constants_filename = sys.argv[2]
|
constants_filename = sys.argv[2]
|
||||||
|
|
||||||
with open(methods_filename) as f:
|
with open(methods_filename) as f:
|
||||||
methods = [l.strip().split("\t")[1] for l in f]
|
# module, method_name, signature
|
||||||
|
methods = [l.strip().split("\t") for l in f]
|
||||||
|
|
||||||
print("%d methods" % len(methods))
|
print("%d methods" % len(methods))
|
||||||
|
|
||||||
@ -31,9 +35,25 @@ with open(constants_filename) as f:
|
|||||||
|
|
||||||
print("%d constants" % len(constants))
|
print("%d constants" % len(constants))
|
||||||
|
|
||||||
|
# Add JavaScripts
|
||||||
|
jss = []
|
||||||
|
for fn in glob.glob("static/js/*.js"):
|
||||||
|
jss.append(open(fn).read())
|
||||||
|
|
||||||
|
print("%d javascripts" % len(jss))
|
||||||
|
|
||||||
|
L = []
|
||||||
for method in methods:
|
for method in methods:
|
||||||
n = 0
|
n = 0
|
||||||
for c in constants:
|
for c in constants:
|
||||||
if method in c:
|
if method[1] in c:
|
||||||
n += 1
|
n += 1
|
||||||
print("%s\t%s" % (method, n))
|
nj = 0
|
||||||
|
for js in jss:
|
||||||
|
if method[1] in js:
|
||||||
|
nj += 1
|
||||||
|
L.append(method + [n, nj])
|
||||||
|
|
||||||
|
# Sort by decreasing popularity
|
||||||
|
L.sort(key=lambda x: (x[-1] + x[-2], x[1]), reverse=True)
|
||||||
|
print("\n".join(["%s\t%s\t%s\t%d\t%d" % tuple(l) for l in L]))
|
||||||
|
@ -7,7 +7,8 @@ Useful to check if an API function is used in a generated web page !
|
|||||||
Usage:
|
Usage:
|
||||||
extract_code_strings.py source.py ... > string-constants.txt
|
extract_code_strings.py source.py ... > string-constants.txt
|
||||||
|
|
||||||
(replace RT by an existing departement id)
|
|
||||||
|
Résultat utilisé par check_zope_usage.py
|
||||||
|
|
||||||
E. Viennet 2021-01-09
|
E. Viennet 2021-01-09
|
||||||
"""
|
"""
|
||||||
@ -17,7 +18,7 @@ import sys
|
|||||||
import ast
|
import ast
|
||||||
import types
|
import types
|
||||||
|
|
||||||
L = []
|
# L = []
|
||||||
for srcfilename in sys.argv[1:]:
|
for srcfilename in sys.argv[1:]:
|
||||||
# print("processing %s" % srcfilename, file=sys.stderr)
|
# print("processing %s" % srcfilename, file=sys.stderr)
|
||||||
with open(srcfilename) as f:
|
with open(srcfilename) as f:
|
||||||
|
Loading…
Reference in New Issue
Block a user