mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-10 08:04:16 +00:00
adding more info on actions with verbose (#83)
This commit is contained in:
@@ -32,10 +32,15 @@ class Cmd:
|
||||
|
||||
class Action(Cmd):
|
||||
|
||||
def __init__(self, key, action, *args):
|
||||
def __init__(self, key, kind, action, *args):
|
||||
super(Action, self).__init__(key, action)
|
||||
self.kind = kind
|
||||
self.args = args
|
||||
|
||||
def __str__(self):
|
||||
out = '{}: \"{}\" with args: {}'
|
||||
return out.format(self.key, self.action, self.args)
|
||||
|
||||
def execute(self):
|
||||
"""execute the action in the shell"""
|
||||
ret = 1
|
||||
|
||||
@@ -181,12 +181,14 @@ class Cfg:
|
||||
for k2, v2 in items:
|
||||
if k not in self.actions:
|
||||
self.actions[k] = {}
|
||||
self.actions[k][k2] = Action(k2, v2)
|
||||
self.actions[k][k2] = Action(k2, k, v2)
|
||||
else:
|
||||
# parse naked actions as post actions
|
||||
if self.key_actions_post not in self.actions:
|
||||
self.actions[self.key_actions_post] = {}
|
||||
self.actions[self.key_actions_post][k] = Action(k, v)
|
||||
self.actions[self.key_actions_post][k] = Action(k,
|
||||
'',
|
||||
v)
|
||||
|
||||
# parse read transformations
|
||||
if self.key_trans_r in self.content:
|
||||
@@ -383,24 +385,24 @@ class Cfg:
|
||||
action = None
|
||||
if self.key_actions_pre in self.actions and \
|
||||
entry in self.actions[self.key_actions_pre]:
|
||||
key = self.key_actions_pre
|
||||
kind = self.key_actions_pre
|
||||
if not args:
|
||||
action = self.actions[self.key_actions_pre][entry]
|
||||
else:
|
||||
a = self.actions[self.key_actions_pre][entry].action
|
||||
action = Action(key, a, *args)
|
||||
action = Action(entry, kind, a, *args)
|
||||
elif self.key_actions_post in self.actions and \
|
||||
entry in self.actions[self.key_actions_post]:
|
||||
key = self.key_actions_post
|
||||
kind = self.key_actions_post
|
||||
if not args:
|
||||
action = self.actions[self.key_actions_post][entry]
|
||||
else:
|
||||
a = self.actions[self.key_actions_post][entry].action
|
||||
action = Action(key, a, *args)
|
||||
action = Action(entry, kind, a, *args)
|
||||
else:
|
||||
self.log.warn('unknown action \"{}\"'.format(entry))
|
||||
continue
|
||||
res[key].append(action)
|
||||
res[kind].append(action)
|
||||
return res
|
||||
|
||||
def _parse_trans(self, trans, read=True):
|
||||
|
||||
Reference in New Issue
Block a user