forked from robcarver17/pysystemtrade
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstage.py
52 lines (37 loc) · 1.19 KB
/
stage.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
from syscore.objects import get_methods
from syslogging.logger import *
from systems.basesystem import System
class SystemStage(object):
"""
Default stage object: we inherit from this, rather than use 'in the raw'
Here is the standard header to use for stages:
Create a SystemStage for doing something
KEY INPUT: system.....method(args)
found in self.method(args)
KEY OUTPUT: system.stage_name.method(args)
Name: stage_name
"""
@property
def name(self):
return "Need to replace method when inheriting"
def __repr__(self):
return "SystemStage '%s' Try %s.methods()" % (
self.name,
self.name,
)
def methods(self):
return get_methods(self)
def system_init(self, system: System):
# method called once we have a system
self._parent = system
# and a log
log = system.log.setup(stage=self.name)
self._log = log
@property
def log(self) -> pst_logger:
log = getattr(self, "_log", get_logger(""))
return log
@property
def parent(self) -> System:
parent = getattr(self, "_parent", None)
return parent