예제 #1
0
            if x >= 0:
                line = line[:x]
            # See if there's anything left
            line.strip()
            if not line:
                continue
            line_list = line.split()
            if len(line_list) != 1:
                msg = "Syntax Error %s:%d: %s" \
                    % (config_file, lineno, line)
                raise InputError(msg)
            module_name = line_list[0]
            __import__(module_name, globals(), locals())


commands = Commands('pdk')
ws = 'pdk.workspace'
#commands.easy_map('audit', 'pdk.audit','audit')
#commands.easy_map('push', ws, 'push')
commands.easy_map('pull', ws, 'pull')
commands.easy_map('status', ws, 'status')
commands.easy_map('log', ws, 'log')
#commands.easy_map('update', ws, 'update')
commands.easy_map('commit', ws, 'commit')
commands.easy_map('add', ws, 'add')
commands.easy_map('remove', ws, 'remove')
commands.easy_map('revert', ws, 'revert')
commands.easy_map('cat', ws, 'cat')
commands.easy_map('repogen', ws, 'repogen')
commands.easy_map('mediagen', ws, 'mediagen')
commands.easy_map('dumpmeta', ws, 'dumpmeta')
예제 #2
0
    def test_iterate(self):
        commands = Commands('base')
        command = DirectCommand(dummy_function2)
        commands.map(['a'], command)
        commands.map(['b', 'c'], command)
        commands.map(['d'], command)
        commands.map(['e', 'f', 'g'], command)
        commands.alias(['zz', 'yy'], ['a'])

        expected = [(('base', 'a'), DirectCommand(dummy_function2)),
                    (('base', 'b', 'c'), DirectCommand(dummy_function2)),
                    (('base', 'd'), DirectCommand(dummy_function2)),
                    (('base', 'e', 'f', 'g'), DirectCommand(dummy_function2)),
                    (('base', 'zz', 'yy'), CommandAlias(commands, ['a']))]

        self.assert_equals_long(expected, list(commands))
예제 #3
0
    def test_find(self):
        com = Commands('aaa')
        com.easy_map('a', local_module, 'dummy_function1')
        com.map_direct(['d'], dummy_function2)
        com.map(['g', 'h'], DirectCommand(dummy_function3))
        com.alias(['z', 'y'], ['g', 'h'])

        def ci(function, args):
            return CommandInvoker('aaa', function, CommandArgs(None, args))

        hi = HelpInvoker
        hmi = HelpMultiInvoker

        self.assert_equal(ci(dummy_function1, ['1', '2', '3']),
                          com.find(['a', '1', '2', '3']))
        self.assert_equal(ci(dummy_function3, ['1', '2', '3']),
                          com.find(['g', 'h', '1', '2', '3']))
        self.assert_equal(ci(dummy_function3, ['1', '2', '3']),
                          com.find(['z', 'y', '1', '2', '3']))
        self.assert_equal(hi(['aaa', 'a'], dummy_function1),
                          com.find(['help', 'a', '1', '2', '3']))
        self.assert_equal(hi(['aaa', 'g', 'h'], dummy_function3),
                          com.find(['g', 'help', 'h', '1', '2', '3']))
        self.assert_equal(hmi(['aaa', 'g'], com.commands['g']),
                          com.find(['help', 'g', '1', '2', '3']))
        self.assert_equal(hmi(['aaa', 'g'], com.commands['g']),
                          com.find(['g']))
        self.assert_equal(ci(dummy_function2, ['1', '2', '3']),
                          com.find(['d', '1', '2', '3']))

        try:
            com.find(['zzzzzz'])
        except InputError:
            pass
        else:
            self.fail('Should have thrown InputError!')
예제 #4
0
            x = line.find('#')
            if x >= 0:
                line = line[:x]
            # See if there's anything left
            line.strip()
            if not line:
                continue
            line_list = line.split()
            if len(line_list) != 1:
                msg = "Syntax Error %s:%d: %s" \
                    % (config_file, lineno, line)
                raise InputError(msg)
            module_name = line_list[0]
            __import__(module_name, globals(), locals())

commands = Commands('pdk')
ws = 'pdk.workspace'
#commands.easy_map('audit', 'pdk.audit','audit')
#commands.easy_map('push', ws, 'push')
commands.easy_map('pull', ws, 'pull')
commands.easy_map('status', ws, 'status')
commands.easy_map('log', ws, 'log')
#commands.easy_map('update', ws, 'update')
commands.easy_map('commit', ws, 'commit')
commands.easy_map('add', ws, 'add')
commands.easy_map('remove', ws, 'remove')
commands.easy_map('revert', ws, 'revert')
commands.easy_map('cat', ws, 'cat')
commands.easy_map('repogen', ws,'repogen')
commands.easy_map('mediagen', ws, 'mediagen')
commands.easy_map('dumpmeta', ws, 'dumpmeta')
예제 #5
0
    def test_iterate(self):
        commands = Commands('base')
        command = DirectCommand(dummy_function2)
        commands.map(['a'], command)
        commands.map(['b', 'c'], command)
        commands.map(['d'], command)
        commands.map(['e', 'f', 'g'], command)
        commands.alias(['zz', 'yy'], ['a'])

        expected = [
            (('base', 'a'), DirectCommand(dummy_function2)),
            (('base', 'b', 'c'), DirectCommand(dummy_function2)),
            (('base', 'd'), DirectCommand(dummy_function2)),
            (('base', 'e', 'f', 'g'), DirectCommand(dummy_function2)),
            (('base', 'zz', 'yy'), CommandAlias(commands, ['a'])) ]

        self.assert_equals_long(expected, list(commands))
예제 #6
0
    def test_find(self):
        com = Commands('aaa')
        com.easy_map('a', local_module, 'dummy_function1')
        com.map_direct(['d'], dummy_function2)
        com.map(['g', 'h'], DirectCommand(dummy_function3))
        com.alias(['z', 'y'], ['g', 'h'])

        def ci(function, args):
            return CommandInvoker('aaa', function, CommandArgs(None, args))
        hi = HelpInvoker
        hmi = HelpMultiInvoker

        self.assert_equal(ci(dummy_function1, ['1', '2', '3']),
                          com.find(['a', '1', '2', '3']))
        self.assert_equal(ci(dummy_function3, ['1', '2', '3']),
                          com.find(['g', 'h', '1', '2', '3']))
        self.assert_equal(ci(dummy_function3, ['1', '2', '3']),
                          com.find(['z', 'y', '1', '2', '3']))
        self.assert_equal(hi(['aaa', 'a'], dummy_function1),
                          com.find(['help', 'a', '1', '2', '3']))
        self.assert_equal(hi(['aaa', 'g', 'h'], dummy_function3),
                          com.find(['g', 'help', 'h', '1', '2', '3']))
        self.assert_equal(hmi(['aaa', 'g'], com.commands['g']),
                          com.find(['help', 'g', '1', '2', '3']))
        self.assert_equal(hmi(['aaa', 'g'], com.commands['g']),
                          com.find(['g']))
        self.assert_equal(ci(dummy_function2, ['1', '2', '3']),
                          com.find(['d', '1', '2', '3']))

        try:
            com.find(['zzzzzz'])
        except InputError:
            pass
        else:
            self.fail('Should have thrown InputError!')