MCPcopy
hub / github.com/deadc0de6/dotdrop / execute

Function execute

dotdrop/dotdrop.py:41–73  ·  view source on GitHub ↗

execute actions and return True, None if ok False, errstring if issue

()

Source from the content-addressed store, hash-verified

39def action_executor(opts, actions, defactions, templater, post=False):
40 """closure for action execution"""
41 def execute():
42 """
43 execute actions and return
44 True, None if ok
45 False, errstring if issue
46 """
47 actiontype = 'pre' if not post else 'post'
48
49 # execute default actions
50 for action in defactions:
51 if opts.dry:
52 LOG.dry(f'would execute def-{actiontype}-action: {action}')
53 continue
54 LOG.dbg(f'executing def-{actiontype}-action: {action}')
55 ret = action.execute(templater=templater, debug=opts.debug)
56 if not ret:
57 err = f'def-{actiontype}-action \"{action.key}\" failed'
58 LOG.err(err)
59 return False, err
60
61 # execute actions
62 for action in actions:
63 if opts.dry:
64 err = f'would execute {actiontype}-action: {action}'
65 LOG.dry(err)
66 continue
67 LOG.dbg(f'executing {actiontype}-action: {action}')
68 ret = action.execute(templater=templater, debug=opts.debug)
69 if not ret:
70 err = f'{actiontype}-action \"{action.key}\" failed'
71 LOG.err(err)
72 return False, err
73 return True, None
74 return execute
75
76

Callers

nothing calls this directly

Calls 4

dryMethod · 0.80
dbgMethod · 0.80
executeMethod · 0.80
errMethod · 0.80

Tested by

no test coverage detected