DocScoDoc/misc/check_zope_usage.py

40 lines
1.0 KiB
Python
Executable File

#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Check usage of (published) ScoDoc methods
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
methods-list.txt : fichier texte, module et un nom de méthode / ligne
ZScoUsers get_userlist
string-constants.txt : les constantes chaines, extraites par extract_code_strings.py
"scolars.py" "</li><li>"
E. Viennet 2021-01-09
"""
from __future__ import print_function
import sys
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]
print("%d methods" % len(methods))
with open(constants_filename) as f:
constants = [l[:-1].split("\t")[1] for l in f]
print("%d constants" % len(constants))
for method in methods:
n = 0
for c in constants:
if method in c:
n += 1
print("%s\t%s" % (method, n))