File tree Expand file tree Collapse file tree 5 files changed +41
-26
lines changed Expand file tree Collapse file tree 5 files changed +41
-26
lines changed Original file line number Diff line number Diff line change 20
20
@router .get ("" , response_model = FindAllStrategyResult )
21
21
@inject
22
22
def get_strategy_list (
23
- schema : FindBase = Depends (),
24
23
service : StrategyService = Depends (Provide [Container .strategy_service ]),
25
24
):
26
- return service .get_list (schema )
25
+ response = service .list_all_strategies ()
26
+ print (" " )
27
+ print (" " )
28
+ print (" " )
29
+ print ("---------------------------------------" )
30
+ return response
27
31
28
32
29
33
# @router.get("{id}", response_model=FindStrategyResult)
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ import os
2
+ import importlib
3
+ from app .engine .check_base_strategy_class import check_class_methods_and_variables
4
+
5
+
6
+ def all_engine_strategies ():
7
+ strategies = []
8
+ for file in os .listdir ("app/engine" ):
9
+ if (
10
+ file .endswith (".py" ) and
11
+ file != "__init__.py" and
12
+ file != "check_base_strategy_class.py" and
13
+ file != "all_engine_strategies.py" ):
14
+ strategy = file [:- 3 ]
15
+ strategies .append (strategy )
16
+
17
+ # import all strategies and check if they are valid with check_base_strategy_class
18
+ # if not, remove them from the list
19
+
20
+ for strategy in strategies :
21
+ module = importlib .import_module (f"app.engine.{ strategy } " )
22
+ # get classes Name and check if it is a valid strategy
23
+ classes = [getattr (module , name )
24
+ for name in dir (module ) if name [0 ].isupper ()]
25
+ for Class in classes :
26
+ if not check_class_methods_and_variables (Class ):
27
+ strategies .remove (strategy )
28
+ break
29
+
30
+ return strategies
Original file line number Diff line number Diff line change 1
1
from app .core .exceptions import ConflictError
2
2
from app .repository .strategy_repository import StrategyRepository
3
3
from app .services .base_service import BaseService
4
- from app .engine .import_app_engine_modules import import_app_engine_modules
4
+ from app .engine .all_engine_strategies import all_engine_strategies
5
+
5
6
6
7
class StrategyService (BaseService ):
7
8
def __init__ (self , strategy_repository : StrategyRepository ):
8
9
self .strategy_repository = strategy_repository
9
10
super ().__init__ (strategy_repository )
10
11
11
- def list_all_strategies (self , schema ):
12
- all_strategies = import_app_engine_modules
12
+ def list_all_strategies (self ):
13
+ all_strategies = all_engine_strategies ()
14
+ print (all_strategies )
13
15
pass
14
16
15
17
def get_strategy_by_id (self , id ):
You can’t perform that action at this time.
0 commit comments