예제 #1
0
파일: main.py 프로젝트: aliles/begins
    def start(self, args=None):
        """Begin command line program

        By default will use the command line arguments passed when Python was
        initially started. New arguments can be passed through the args
        parameter.
        """
        commands = [[]]
        args = args if args is not None else sys.argv[1:]
        if len(args) > 0:
            commands = [list(group) for key, group in itertools.groupby(args, lambda x: x == self._cmd_delim) if not key]
        options = []
        for command in commands:
            opts = self._parser.parse_args(command)
            options.append(opts)
        context.clear()
        context.opts_next = tuple(options)
        for count, opts in enumerate(options):
            context.opts_next = context.opts_next[1:]
            context.opts_current = opts
            cmdline.apply_options(self.__wrapped__, opts,
                    run_main=(count==0), sub_group=self._group,
                    collector=self._collector)
            context.opts_previous += (opts,)
        context.opts_current = None
        return context.last_return
예제 #2
0
    def start(self, args=None):
        """Begin command line program

        By default will use the command line arguments passed when Python was
        initially started. New arguments can be passed through the args
        parameter.
        """
        commands = [[]]
        args = args if args is not None else sys.argv[1:]
        if len(args) > 0:
            commands = [
                list(group) for key, group in itertools.groupby(
                    args, lambda x: x == self._cmd_delim) if not key
            ]
        options = []
        for command in commands:
            opts = self._parser.parse_args(command)
            options.append(opts)
        context.clear()
        context.opts_next = tuple(options)
        for count, opts in enumerate(options):
            context.opts_next = context.opts_next[1:]
            context.opts_current = opts
            cmdline.apply_options(self.__wrapped__,
                                  opts,
                                  run_main=(count == 0),
                                  sub_group=self._group,
                                  collector=self._collector)
            context.opts_previous += (opts, )
        context.opts_current = None
        return context.last_return
예제 #3
0
 def setUp(self):
     context.clear()
예제 #4
0
 def setUp(self):
     context.clear()