コード例 #1
0
ファイル: run.py プロジェクト: hemanthk92/CaseRoutingDemo
 def GenerateArgs(self, namespace, module_path):
     kwargs = namespace.kwargs or {}
     self.__completer = _GetCompleter(module_path,
                                      qualify=namespace.qualify,
                                      **kwargs)
     args = {}
     if self.__completer.parameters:
         for parameter in self.__completer.parameters:
             dest = parameter_info_lib.GetDestFromParam(parameter.name)
             if hasattr(namespace, dest):
                 # Don't add if its already been added.
                 continue
             flag = parameter_info_lib.GetFlagFromDest(dest)
             args[parameter.name] = base.Argument(
                 flag,
                 dest=dest,
                 category='RESOURCE COMPLETER',
                 help='{} `{}` parameter value.'.format(
                     self.__completer.__class__.__name__, parameter.name))
     self.__argument = base.Argument(
         'resource_to_complete',
         nargs='?',
         help=(
             'The partial resource name to complete. Omit to enter an '
             'interactive loop that reads a partial resource name from the '
             'input and lists the possible prefix matches on the output '
             'or displays an ERROR message.'))
     args[self.__argument.name] = self.__argument
     return args
コード例 #2
0
ファイル: run.py プロジェクト: hiroshiyoshida1980/jpopjam
 def GenerateArgs(self, namespace, module_path):
     args = []
     presentation_kwargs = namespace.resource_presentation_kwargs or {}
     # Add the args that correspond to the resource arg, but make them
     # non-required.
     if namespace.resource_spec_path:
         spec = _GetPresentationSpec(namespace.resource_spec_path,
                                     **presentation_kwargs)
         info = concept_parsers.ConceptParser([spec]).GetInfo(spec.name)
         for arg in info.GetAttributeArgs():
             if arg.name.startswith('--'):
                 arg.kwargs['required'] = False
             else:
                 arg.kwargs['nargs'] = '?' if not spec.plural else '*'
             args.append(arg)
     kwargs = namespace.kwargs or {}
     self.__completer = _GetCompleter(
         module_path,
         qualify=namespace.qualify,
         resource_spec=namespace.resource_spec_path,
         presentation_kwargs=presentation_kwargs,
         attribute=namespace.attribute,
         **kwargs)
     if self.__completer.parameters:
         for parameter in self.__completer.parameters:
             dest = parameter_info_lib.GetDestFromParam(parameter.name)
             if hasattr(namespace, dest):
                 # Don't add if its already been added.
                 continue
             flag = parameter_info_lib.GetFlagFromDest(dest)
             arg = base.Argument(flag,
                                 dest=dest,
                                 category='RESOURCE COMPLETER',
                                 help='{} `{}` parameter value.'.format(
                                     self.__completer.__class__.__name__,
                                     parameter.name))
             args.append(arg)
     self.__argument = base.Argument(
         'resource_to_complete',
         nargs='?',
         help=(
             'The partial resource name to complete. Omit to enter an '
             'interactive loop that reads a partial resource name from the '
             'input and lists the possible prefix matches on the output '
             'or displays an ERROR message.'))
     args.append(self.__argument)
     return args
コード例 #3
0
 def RunSubTest(self, param, prefix=None):
     return parameter_info_lib.GetDestFromParam(param, prefix=prefix)