예제 #1
0
    def test_ask_for_actions_and_apply2(self):
        failed_actions = set()
        action = ApplyPatchAction()
        action2 = ChainPatchAction()
        args = [
            self.console_printer,
            Section(''), [action.get_metadata(),
                          action2.get_metadata()], {
                              'ApplyPatchAction': action,
                              'ChainPatchAction': action2
                          }, failed_actions,
            Result('origin', 'message'), {}, {}, {}
        ]

        with simulate_console_inputs('c', 'a') as generator:
            ask_for_action_and_apply(*args)
            self.assertEqual(generator.last_input, 1)
            self.assertIn('ApplyPatchAction', failed_actions)

        with simulate_console_inputs('c', 'n') as generator:
            ask_for_action_and_apply(*args)
            self.assertEqual(generator.last_input, 1)
            self.assertNotIn('ChainPatchAction', failed_actions)

        with simulate_console_inputs('c', 'x') as generator:
            ask_for_action_and_apply(*args)
            self.assertEqual(generator.last_input, 0)
            self.assertNotIn('ChainPatchAction', failed_actions)

        with simulate_console_inputs('c', 'o') as generator:
            ask_for_action_and_apply(*args)
            self.assertEqual(generator.last_input, 0)
            self.assertNotIn('ChainPatchAction', failed_actions)
예제 #2
0
                           'needed by {} for section \"{}\": ')
STR_LINE_DOESNT_EXIST = ('The line belonging to the following result '
                         'cannot be printed because it refers to a line '
                         "that doesn't seem to exist in the given file.")
STR_PROJECT_WIDE = 'Project wide:'
STR_ENTER_NUMBER = 'Enter number (Ctrl-{} to exit): '.format(
    'Z' if platform.system() == 'Windows' else 'D')
FILE_NAME_COLOR = 'blue'
FILE_LINES_COLOR = 'blue'
CAPABILITY_COLOR = 'green'
HIGHLIGHTED_CODE_COLOR = 'red'
SUCCESS_COLOR = 'green'
REQUIRED_SETTINGS_COLOR = 'green'
CLI_ACTIONS = (OpenEditorAction(), ApplyPatchAction(),
               PrintDebugMessageAction(), PrintMoreInfoAction(),
               ShowPatchAction(), IgnoreResultAction(), ChainPatchAction(),
               ShowAppliedPatchesAction())
DIFF_EXCERPT_MAX_SIZE = 4


def color_letter(console_printer, line):
    x = -1
    y = -1
    letter = ''
    for i, l in enumerate(line, 0):
        if line[i] == '(':
            x = i
        if line[i] == ')':
            y = i
        if l.isupper() and x != -1:
            letter = l
예제 #3
0
STR_PROJECT_WIDE = 'Project wide:'
STR_ENTER_NUMBER = 'Enter number (Ctrl-{} to exit): '.format(
    'Z' if platform.system() == 'Windows' else 'D')
FILE_NAME_COLOR = 'blue'
FILE_LINES_COLOR = 'blue'
CAPABILITY_COLOR = 'green'
HIGHLIGHTED_CODE_COLOR = 'red'
SUCCESS_COLOR = 'green'
REQUIRED_SETTINGS_COLOR = 'green'
CLI_ACTIONS = (OpenEditorAction(),
               ApplyPatchAction(),
               PrintDebugMessageAction(),
               PrintMoreInfoAction(),
               ShowPatchAction(),
               IgnoreResultAction(),
               ChainPatchAction(),
               ShowAppliedPatchesAction())
DIFF_EXCERPT_MAX_SIZE = 4


def color_letter(console_printer, line):
    x = -1
    y = -1
    letter = ''
    for i, l in enumerate(line, 0):
        if line[i] == '(':
            x = i
        if line[i] == ')':
            y = i
        if l.isupper() and x != -1:
            letter = l