def check_args_variant(segment, args, data, context, echoerr): argspec = getconfigargspec(segment) present_args = set(args) all_args = set(argspec.args) required_args = set(argspec.args[:-len(argspec.defaults)]) hadproblem = False if required_args - present_args: echoerr(context='Error while checking segment arguments (key {key})'.format(key=context_key(context)), context_mark=args.mark, problem='some of the required keys are missing: {0}'.format(list_sep.join(required_args - present_args))) hadproblem = True if not all_args >= present_args: echoerr(context='Error while checking segment arguments (key {key})'.format(key=context_key(context)), context_mark=args.mark, problem='found unknown keys: {0}'.format(list_sep.join(present_args - all_args)), problem_mark=next(iter(present_args - all_args)).mark) hadproblem = True if isinstance(segment, ThreadedSegment): for key in set(threaded_args_specs) & present_args: proceed, khadproblem = threaded_args_specs[key].match(args[key], args.mark, data, context + ((key, args[key]),), echoerr) if khadproblem: hadproblem = True if not proceed: return hadproblem return hadproblem
def format_args(self): argspec = getconfigargspec(self.object) return formatargspec(*argspec, formatvalue=formatvalue).replace('\\', '\\\\')