An action to execute
| 109 | |
| 110 | |
| 111 | class Action(Cmd): |
| 112 | """An action to execute""" |
| 113 | |
| 114 | pre = 'pre' |
| 115 | post = 'post' |
| 116 | descr = 'action' |
| 117 | |
| 118 | def __init__(self, key, kind, action): |
| 119 | """constructor |
| 120 | @key: action key |
| 121 | @kind: type of action (pre or post) |
| 122 | @action: action string |
| 123 | """ |
| 124 | super().__init__(key, action) |
| 125 | self.kind = kind |
| 126 | self.args = [] |
| 127 | |
| 128 | def copy(self, args): |
| 129 | """return a copy of this object with arguments""" |
| 130 | action = Action(self.key, self.kind, self.action) |
| 131 | action.args = args |
| 132 | return action |
| 133 | |
| 134 | @classmethod |
| 135 | def parse(cls, key, value): |
| 136 | """parse key value into object""" |
| 137 | val = {} |
| 138 | val['kind'], val['action'] = value |
| 139 | return cls(key=key, **val) |
| 140 | |
| 141 | def __str__(self): |
| 142 | out = f'{self.key}: [{self.kind}] \"{self.action}\"' |
| 143 | return out |
| 144 | |
| 145 | def __repr__(self): |
| 146 | return f'action({self.__str__()})' |
| 147 | |
| 148 | |
| 149 | class Transform(Cmd): |
no outgoing calls