diff --git a/misc/check_zope_usage.py b/misc/check_zope_usage.py index 85ffd7ab81..d0b8fa4aba 100755 --- a/misc/check_zope_usage.py +++ b/misc/check_zope_usage.py @@ -5,10 +5,12 @@ Quick method: just grep method name in all constant strings from the source code base. 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 + comme extrait par zopelistmethods.py + string-constants.txt : les constantes chaines, extraites par extract_code_strings.py "scolars.py" "
  • " @@ -17,12 +19,14 @@ E. Viennet 2021-01-09 from __future__ import print_function import sys +import glob methods_filename = sys.argv[1] constants_filename = sys.argv[2] 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)) @@ -31,9 +35,25 @@ with open(constants_filename) as f: 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: n = 0 for c in constants: - if method in c: + if method[1] in c: 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])) diff --git a/misc/extract_code_strings.py b/misc/extract_code_strings.py index 01f894e2fc..a8a41f45c4 100755 --- a/misc/extract_code_strings.py +++ b/misc/extract_code_strings.py @@ -7,7 +7,8 @@ Useful to check if an API function is used in a generated web page ! Usage: 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 """ @@ -17,7 +18,7 @@ import sys import ast import types -L = [] +# L = [] for srcfilename in sys.argv[1:]: # print("processing %s" % srcfilename, file=sys.stderr) with open(srcfilename) as f: