mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-08 10:49:17 +00:00
adding support for pre/post actions
This commit is contained in:
@@ -25,6 +25,8 @@ class Cfg:
|
||||
|
||||
# key actions
|
||||
key_actions = 'actions'
|
||||
key_actions_pre = 'pre'
|
||||
key_actions_post = 'post'
|
||||
|
||||
# key transformations
|
||||
key_trans = 'trans'
|
||||
@@ -101,12 +103,26 @@ class Cfg:
|
||||
|
||||
def _parse_actions(self, actions, entries):
|
||||
""" parse actions specified for an element """
|
||||
res = []
|
||||
res = {
|
||||
self.key_actions_pre: [],
|
||||
self.key_actions_post: [],
|
||||
'actions': []
|
||||
}
|
||||
for entry in entries:
|
||||
if entry not in actions.keys():
|
||||
key = 'actions'
|
||||
action = None
|
||||
if self.key_actions_pre in actions and entry in actions[self.key_actions_pre]:
|
||||
key = self.key_actions_pre
|
||||
action = actions[self.key_actions_pre][entry]
|
||||
elif self.key_actions_post in actions and entry in actions[self.key_actions_post]:
|
||||
key = self.key_actions_post
|
||||
action = actions[self.key_actions_post][entry]
|
||||
elif entry not in actions.keys():
|
||||
self.log.warn('unknown action \"{}\"'.format(entry))
|
||||
continue
|
||||
res.append(actions[entry])
|
||||
else:
|
||||
action = actions[entry]
|
||||
res[key].append(action)
|
||||
return res
|
||||
|
||||
def _complete_configs(self):
|
||||
@@ -124,7 +140,13 @@ class Cfg:
|
||||
if self.key_actions in self.content:
|
||||
if self.content[self.key_actions] is not None:
|
||||
for k, v in self.content[self.key_actions].items():
|
||||
self.actions[k] = Action(k, v)
|
||||
if k in [self.key_actions_pre, self.key_actions_post]:
|
||||
for k2, v2 in self.content[self.key_actions][k].items():
|
||||
if k not in self.actions:
|
||||
self.actions[k] = {}
|
||||
self.actions[k][k2] = Action(k2, v2)
|
||||
else:
|
||||
self.actions[k] = Action(k, v)
|
||||
|
||||
# parse all transformations
|
||||
if self.key_trans in self.content:
|
||||
|
||||
Reference in New Issue
Block a user