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]¶ (A)pply 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, applied_actions=())¶
-
coalib.results.result_actions.DoNothingAction module¶
coalib.results.result_actions.GeneratePatchesAction module¶
-
class
coalib.results.result_actions.GeneratePatchesAction.
GeneratePatchesAction
[source]¶ Bases:
coalib.results.result_actions.ResultAction.ResultAction
-
SUCCESS_MESSAGE
= 'Patch generated successfully.'¶
-
static
is_applicable
(result: coalib.results.Result.Result, original_file_dict, file_diff_dict, applied_actions=())¶
-
-
coalib.results.result_actions.GeneratePatchesAction.
create_arg_parser
(files, bears)[source]¶ A function that generates a default_arg_parser.
Parameters: - files – A list that contains filenames.
- bears – A list that contains name of bears.
Returns: An object of type default_arg_parser.
-
coalib.results.result_actions.GeneratePatchesAction.
filter_bears
(language)[source]¶ Filter bears by language.
Parameters: language – The language to filter with. Returns: A list of bears.
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 (I)gnore 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, applied_actions=())[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. Additionally, the action should not have been applied to the current result before.
-
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]¶ (O)pen file
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
andfile_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
andcolumn
.
-
coalib.results.result_actions.PrintAspectAction module¶
-
class
coalib.results.result_actions.PrintAspectAction.
PrintAspectAction
[source]¶ Bases:
coalib.results.result_actions.ResultAction.ResultAction
coalib.results.result_actions.PrintDebugMessageAction module¶
-
class
coalib.results.result_actions.PrintDebugMessageAction.
PrintDebugMessageAction
[source]¶ Bases:
coalib.results.result_actions.ResultAction.ResultAction
coalib.results.result_actions.PrintMoreInfoAction module¶
-
class
coalib.results.result_actions.PrintMoreInfoAction.
PrintMoreInfoAction
[source]¶ Bases:
coalib.results.result_actions.ResultAction.ResultAction
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, applied_actions=())[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.
Applied_actions: List of actions names that have already been applied for the current result. Action names are stored in order of application.
-
coalib.results.result_actions.ShowAppliedPatchesAction module¶
-
class
coalib.results.result_actions.ShowAppliedPatchesAction.
ShowAppliedPatchesAction
[source]¶ Bases:
coalib.results.result_actions.ResultAction.ResultAction
-
SUCCESS_MESSAGE
= 'Applied patches shown'¶
-
static
is_applicable
(result: coalib.results.Result.Result, original_file_dict, file_diff_dict, applied_actions=())¶
-
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, no_color: bool = False, show_result_on_top: bool = False)[source]¶ (S)how patch
Parameters: - no_color – 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.)
-
Module contents¶
The result_actions package holds objects deriving from ResultAction. A ResultAction represents an action that an be applied to a result.