coalib.results.result_actions package

Submodules

coalib.results.result_actions.ApplyPatchAction module

class coalib.results.result_actions.ApplyPatchAction.ApplyPatchAction[source]

Bases: coalib.results.result_actions.ResultAction.ResultAction

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

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[source]

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)[source]

Add ignore comment

get_ignore_comment(origin, language)[source]

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)[source]

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[source]

Bases: coalib.results.result_actions.ResultAction.ResultAction

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

Open file(s)

Parameters:editor – The editor to open the file with.
build_editor_call_args(editor, editor_info, filenames)[source]

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)[source]

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[source]

Bases: coalib.results.result_actions.ResultAction.ResultAction

apply(result, original_file_dict, file_diff_dict)[source]

Print Aspect Information

static is_applicable(result: coalib.results.Result.Result, original_file_dict, file_diff_dict)[source]

coalib.results.result_actions.PrintDebugMessageAction module

class coalib.results.result_actions.PrintDebugMessageAction.PrintDebugMessageAction[source]

Bases: coalib.results.result_actions.ResultAction.ResultAction

apply(result, original_file_dict, file_diff_dict)[source]

Print debug message

static is_applicable(result: coalib.results.Result.Result, original_file_dict, file_diff_dict)[source]

coalib.results.result_actions.PrintMoreInfoAction module

class coalib.results.result_actions.PrintMoreInfoAction.PrintMoreInfoAction[source]

Bases: coalib.results.result_actions.ResultAction.ResultAction

apply(result, original_file_dict, file_diff_dict)[source]

Print more info

static is_applicable(result: coalib.results.Result.Result, original_file_dict, file_diff_dict)[source]

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[source]

Bases: object

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

No description. Something went wrong.

apply_from_section(result, original_file_dict: dict, file_diff_dict: dict, section: coalib.settings.Section.Section)[source]

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()[source]

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)[source]

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[source]

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)[source]

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)[source]
coalib.results.result_actions.ShowPatchAction.format_line(line, real_nr='', sign='|', mod_nr='', symbol='')[source]
coalib.results.result_actions.ShowPatchAction.print_beautified_diff(difflines, printer)[source]
coalib.results.result_actions.ShowPatchAction.print_from_name(printer, line)[source]
coalib.results.result_actions.ShowPatchAction.print_to_name(printer, line)[source]

Module contents

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