Yield args, kwargs pairs for just our recursive options.

    Includes all the options we inherit recursively from our ancestors.
322126
def _recursive_option_registration_args(self):
    
    if self._parent_parser:
      for args, kwargs in self._parent_parser._recursive_option_registration_args():
        yield args, kwargs
    for args, kwargs in self._option_registrations:
      # Note that all subsystem options are implicitly recursive: a subscope of a subsystem
      # scope is another (optionable-specific) instance of the same subsystem, so it needs
      # all the same options.
      if self._scope_info.category == ScopeInfo.SUBSYSTEM or 'recursive' in kwargs:
        yield args, kwargs
689780
def describe_arguments(func):
    

    argspec = inspect.getargspec(func)
    # we should probably raise an exception somewhere if func includes **kwargs
    if argspec.defaults:
        positional_args = argspec.args[:-len(argspec.defaults)]
        keyword_names = argspec.args[-len(argspec.defaults):]
        for arg, default in zip(keyword_names, argspec.defaults):
            yield ('--{}'.format(arg),), {'default': default}
    else:
        positional_args = argspec.args

    for arg in positional_args:
        yield (arg,), {}
    if argspec.varargs:
        yield (argspec.varargs,), {'nargs': '*'}
1333346
def each_recursive(&block) # :yields: node
      self.elements.each {|node|
        block.call(node)
        node.each_recursive(&block)
      }
    end
753575
def extract_kwargs(names:Collection[str], kwargs:KWArgs):
    ""
    new_kwargs = {}
    for arg_name in names:
        if arg_name in kwargs:
            arg_val = kwargs.pop(arg_name)
            new_kwargs[arg_name] = arg_val
    return new_kwargs, kwargs
605587
def flatten(*args):
    ''''''
    for arg in args:
        if isinstance(arg, collections.Iterable) and not isinstance(arg, (str, bytes)):
            yield from flatten(*arg)
        else:
            yield arg
50814
def createArgs(**kwargs):
  
  if len(kwargs) == 0: return [{}]
  kargs = deepcopy(kwargs)
  k1 = kargs.keys()[0]
  values = kargs.pop(k1)
  args = []

  # Get all other combinations
  otherArgs = createArgs(**kargs)

  # Create combinations for values associated with k1
  for v in values:
    newArgs = deepcopy(otherArgs)
    arg = {k1: v}
    for newArg in newArgs:
      newArg.update(arg)
      args.append(newArg)

  return args
141824
def _clone_args(self):
        
        keys = list(self.keys)
        kw = {}
        if self.allow_any or self.extras:
            kw['allow_extra'] = list(self.extras)
            if self.allow_any:
                kw['allow_extra'].append('*')
            kw['allow_extra_trafaret'] = self.extras_trafaret
        if self.ignore_any or self.ignore:
            kw['ignore_extra'] = list(self.ignore)
            if self.ignore_any:
                kw['ignore_any'].append('*')
        return keys, kw
1007057
def make_function_arguments(args,
                            kwonly,
                            varargs,
                            varkwargs,
                            defaults,
                            kw_defaults,
                            annotations):
    
    return ast.arguments(
        args=[ast.arg(arg=a, annotation=annotations.get(a)) for a in args],
        kwonlyargs=[
            ast.arg(arg=a, annotation=annotations.get(a)) for a in kwonly
        ],
        defaults=defaults,
        kw_defaults=list(map(kw_defaults.get, kwonly)),
        vararg=None if varargs is None else ast.arg(
            arg=varargs, annotation=annotations.get(varargs),
        ),
        kwarg=None if varkwargs is None else ast.arg(
            arg=varkwargs, annotation=annotations.get(varkwargs)
        ),
    )
209898
def generator(self,gen,*args,**kwargs):
        
        with self(*args,**kwargs):
            for i in gen:
                yield i
1299637
def gen_all_subclasses(cls: Type) -> Generator[Type, None, None]:
    

    for s1 in cls.__subclasses__():
        yield s1
        for s2 in gen_all_subclasses(s1):
            yield s2
581200
def _branch_descendants(self, branch=None):
        
        branch = branch or self.branch
        for (parent, (child, _, _, _, _)) in self._branches.items():
            if parent == branch:
                yield child
408814
def injectables(**kwargs):
    
    global _INJECTABLES

    original = _INJECTABLES.copy()
    _INJECTABLES.update(kwargs)
    yield
    _INJECTABLES = original
1298685
def get_func_kwargs(func, recursive=True):
    
    import utool as ut
    argspec = ut.get_func_argspec(func)
    if argspec.defaults is None:
        header_kw = {}
    else:
        header_kw = dict(zip(argspec.args[::-1], argspec.defaults[::-1]))
    if argspec.keywords is not None:
        header_kw.update(dict(ut.recursive_parse_kwargs(func)))
    return header_kw
1340144
def GetAncestors(self):
    
    current = self
    while True:
      current = current.GetParent()
      if current is None:
        return
      yield current
1078084
def ancestors(self, recurs=True, context=None):
        
        # FIXME: should be possible to choose the resolution order
        # FIXME: inference make infinite loops possible here
        yielded = {self}
        if context is None:
            context = contextmod.InferenceContext()
        if not self.bases and self.qname() != "builtins.object":
            yield builtin_lookup("object")[1][0]
            return

        for stmt in self.bases:
            with context.restore_path():
                try:
                    for baseobj in stmt.infer(context):
                        if not isinstance(baseobj, ClassDef):
                            if isinstance(baseobj, bases.Instance):
                                baseobj = baseobj._proxied
                            else:
                                continue
                        if not baseobj.hide:
                            if baseobj in yielded:
                                continue
                            yielded.add(baseobj)
                            yield baseobj
                        if not recurs:
                            continue
                        for grandpa in baseobj.ancestors(recurs=True, context=context):
                            if grandpa is self:
                                # This class is the ancestor of itself.
                                break
                            if grandpa in yielded:
                                continue
                            yielded.add(grandpa)
                            yield grandpa
                except exceptions.InferenceError:
                    continue
332430
def get_args_pairs(arguments):
    

    return ' '.join(' '.join(['-' + k, tcl_str(str(v))]) for k, v in arguments.items())
963562
def passing(self, *args, **kwargs):
        
        self.args = args
        self.kwargs = kwargs
        return self