summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2026-05-24 22:56:26 +0200
committerCarl Hetherington <cth@carlh.net>2026-05-24 22:56:26 +0200
commit4ba2e4cc2aa0e272c1b8429db914f568cb636791 (patch)
tree6f60eeb625f63143a241bee144e74fe01e492cf1
parentd9dacc11fcfb222ab38db2c6b16d07126cf47e5d (diff)
fixup! Try to tidy up with vaguely_call().HEADmaster
-rwxr-xr-xcdist20
1 files changed, 14 insertions, 6 deletions
diff --git a/cdist b/cdist
index 6786f12..fd36596 100755
--- a/cdist
+++ b/cdist
@@ -1081,13 +1081,21 @@ class Tree:
with TreeDirectory(self):
return self.cscript[function](self.target, *args, **kwargs)
- def vaguely_call(self, function, **kwargs):
- values = []
+ def vaguely_call(self, function, **potential_args):
+ args = []
+ kwargs = {}
for arg in inspect.getfullargspec(self.cscript[function]).args:
- if arg not in kwargs:
- raise Error('Requested argument %s not provided' % arg)
- values.append(kwargs[arg])
- return self.call(function, values)
+ if arg == 'target':
+ # This gets added in call()
+ continue
+ if arg not in potential_args:
+ raise Error('Requested argument %s for %s not provided' % (arg, function))
+ args.append(potential_args[arg])
+ for arg in inspect.getfullargspec(self.cscript[function]).kwonlyargs:
+ if arg not in potential_args:
+ raise Error('Requested argument %s for %s not provided' % (arg, function))
+ kwargs[arg] = potential_args[arg]
+ return self.call(function, *args, **kwargs)
def add_defaults(self, options):
"""Add the defaults from self into a dict options and returns a new dict"""