coalib.results.result_actions package — coala 0.11.0.rc1 documentation

# coalib.results.result_actions package

## Submodules

## coalib.results.result_actions.ApplyPatchAction module

class `coalib.results.result_actions.ApplyPatchAction.` `ApplyPatchAction`

  Bases: `coalib.results.result_actions.ResultAction.ResultAction`

  `SUCCESS_MESSAGE` = 'Patch applied successfully.'
  `apply`(result, original_file_dict, file_diff_dict, no_orig: bool = False)

    Apply patch

    Parameters: | no_orig – Whether or not to create .orig backup files

  static `is_applicable`(result: coalib.results.Result.Result, original_file_dict, file_diff_dict)

## coalib.results.result_actions.IgnoreResultAction module

class `coalib.results.result_actions.IgnoreResultAction.` `IgnoreResultAction`

  Bases: `coalib.results.result_actions.ResultAction.ResultAction`

  `SUCCESS_MESSAGE` = 'An ignore comment was added to your source code.'
  `apply`(result, original_file_dict, file_diff_dict, language: str, no_orig: bool = False)

    Add ignore comment

  `get_ignore_comment`(origin, language)

    Returns a string of Ignore Comment, depending on the language Supports Single Line Comments

        >>> IgnoreResultAction().get_ignore_comment("Bear", "css")
        '/* Ignore Bear */\n'

    And Multiline Comments

        >>> IgnoreResultAction().get_ignore_comment("Bear", "c")
        '// Ignore Bear\n'

  static `is_applicable`(result: coalib.results.Result.Result, original_file_dict, file_diff_dict)

    For being applicable, the result has to point to a number of files that have to exist i.e. have not been previously deleted.

## coalib.results.result_actions.OpenEditorAction module

class `coalib.results.result_actions.OpenEditorAction.` `OpenEditorAction`

  Bases: `coalib.results.result_actions.ResultAction.ResultAction`

  `SUCCESS_MESSAGE` = 'Changes saved successfully.'
  `apply`(result, original_file_dict, file_diff_dict, editor: str)

    Open file(s)

    Parameters: | editor – The editor to open the file with.

  `build_editor_call_args`(editor, editor_info, filenames)

    Create argument list which will then be used to open an editor for the given files at the correct positions, if applicable.

    Parameters: | editor – The editor to open the file with. editor_info – A dict containing the keys `args` and `file_arg_template`, providing additional call arguments and a template to open files at a position for this editor. filenames – A dict holding one entry for each file to be opened. Keys must be `filename`, `line` and `column`.

  static `is_applicable`(result: coalib.results.Result.Result, original_file_dict, file_diff_dict)

    For being applicable, the result has to point to a number of files that have to exist i.e. have not been previously deleted.

## coalib.results.result_actions.PrintAspectAction module

class `coalib.results.result_actions.PrintAspectAction.` `PrintAspectAction`

  Bases: `coalib.results.result_actions.ResultAction.ResultAction`

  `apply`(result, original_file_dict, file_diff_dict)

    Print Aspect Information

  static `is_applicable`(result: coalib.results.Result.Result, original_file_dict, file_diff_dict)

## coalib.results.result_actions.PrintDebugMessageAction module

class `coalib.results.result_actions.PrintDebugMessageAction.` `PrintDebugMessageAction`

  Bases: `coalib.results.result_actions.ResultAction.ResultAction`

  `apply`(result, original_file_dict, file_diff_dict)

    Print debug message

  static `is_applicable`(result: coalib.results.Result.Result, original_file_dict, file_diff_dict)

## coalib.results.result_actions.PrintMoreInfoAction module

class `coalib.results.result_actions.PrintMoreInfoAction.` `PrintMoreInfoAction`

  Bases: `coalib.results.result_actions.ResultAction.ResultAction`

  `apply`(result, original_file_dict, file_diff_dict)

    Print more info

  static `is_applicable`(result: coalib.results.Result.Result, original_file_dict, file_diff_dict)

## coalib.results.result_actions.ResultAction module

A ResultAction is an action that is applicable to at least some results. This file serves the base class for all result actions, thus providing a unified interface for all actions.

class `coalib.results.result_actions.ResultAction.` `ResultAction`

  Bases: `object`

  `SUCCESS_MESSAGE` = 'The action was executed successfully.'
  `apply`(result, original_file_dict, file_diff_dict, **kwargs)

    No description. Something went wrong.

  `apply_from_section`(result, original_file_dict: dict, file_diff_dict: dict, section: coalib.settings.Section.Section)

    Applies this action to the given results with all additional options given as a section. The file dictionaries are needed for differential results.

    Parameters: | result – The result to apply. original_file_dict – A dictionary containing the files in the state where the result was generated. file_diff_dict – A dictionary containing a diff for every file from the state in the original_file_dict to the current state. This dict will be altered so you do not need to use the return value. section – The section where to retrieve the additional information.
    Returns: | The modified file_diff_dict.

  classmethod `get_metadata`()

    Retrieves metadata for the apply function. The description may be used to advertise this action to the user. The parameters and their help texts are additional information that are needed from the user. You can create a section out of the inputs from the user and use apply_from_section to apply

    :return A FunctionMetadata object.

  static `is_applicable`(result, original_file_dict, file_diff_dict)

    Checks whether the Action is valid for the result type.

    Returns `True` or a string containing the not_applicable message.

    Parameters: | result – The result from the coala run to check if an Action is applicable. original_file_dict – A dictionary containing the files in the state where the result was generated. file_diff_dict – A dictionary containing a diff for every file from the state in the original_file_dict to the current state. This dict will be altered so you do not need to use the return value.

## coalib.results.result_actions.ShowPatchAction module

class `coalib.results.result_actions.ShowPatchAction.` `ShowPatchAction`

  Bases: `coalib.results.result_actions.ResultAction.ResultAction`

  `SUCCESS_MESSAGE` = 'Displayed patch successfully.'
  `apply`(result, original_file_dict, file_diff_dict, colored: bool = True, show_result_on_top: bool = False)

    Show patch

    Parameters: | colored – Whether or not to use colored output. show_result_on_top – Set this to True if you want to show the result info on top. (Useful for e.g. coala_ci.)

  static `is_applicable`(result: coalib.results.Result.Result, original_file_dict, file_diff_dict)

`coalib.results.result_actions.ShowPatchAction.` `format_line`(line, real_nr='', sign='|', mod_nr='', symbol='')

`coalib.results.result_actions.ShowPatchAction.` `print_beautified_diff`(difflines, printer)

`coalib.results.result_actions.ShowPatchAction.` `print_from_name`(printer, line)

`coalib.results.result_actions.ShowPatchAction.` `print_to_name`(printer, line)

## Module contents

The result_actions package holds objects deriving from ResultAction. A ResultAction represents an action that an be applied to a result.