-
Notifications
You must be signed in to change notification settings - Fork 264
/
run_strategy_indexer.py
53 lines (41 loc) · 1.31 KB
/
run_strategy_indexer.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
"""
A script to check that all strategy modules have been included in
`./docs/reference/all_strategies.rst`
"""
import pathlib
import sys
default_index_path = pathlib.Path("./docs/reference/strategy_index.rst")
excluded_modules = ("_strategies", "__init__", "_filters")
def check_module(
module_path: pathlib.Path,
index_path: pathlib.Path = default_index_path,
excluded: tuple = excluded_modules,
) -> bool:
"""
Check if a module name is written in the index of strategies.
Parameters
----------
module_path :
A file path for a module file.
index_path :
A file path for the index file where all strategies are auto documented
excluded :
A collection of module names to be ignored
Returns
-------
boolean :
True/False if module is referenced.
"""
strategies_index = index_path.read_text()
module_name = module_path.stem
if module_name not in excluded and module_name not in strategies_index:
print("{} not in index".format(module_name))
return False
return True
if __name__ == "__main__":
p = pathlib.Path(".")
modules = p.glob("./axelrod/strategies/*.py")
exit_codes = []
for module_path in modules:
exit_codes.append(int(not check_module(module_path)))
sys.exit(max(exit_codes))