planemo.autopygen.source_file_parsing package

Submodules

planemo.autopygen.source_file_parsing.constants module

planemo.autopygen.source_file_parsing.decoy_parser module

exception planemo.autopygen.source_file_parsing.decoy_parser.CustomParserUnavailableException[source]

Bases: Exception

class planemo.autopygen.source_file_parsing.decoy_parser.DecoyParser(name='default')[source]

Bases: ArgumentParser

Decoy class that is injected into code that initializes parser It removes dependency on the internal representation of actions

class Action(section, argument, action, kwargs)[source]

Bases: object

class Section(parent=None, name=None, description=None)[source]

Bases: object

get_actions_recursive()[source]
class Subparsers[source]

Bases: object

add_parser(name, **kwargs)[source]
add_argument(dest, ..., name=value, ...)[source]
add_argument(option_string, option_string, ..., name=value, ...)
add_argument_for_arg_group(section, group)[source]
add_argument_group(*args, **kwargs)[source]
add_subparsers(**kwargs)[source]
create_custom_add_argument_group(original, parent_section)[source]
report_arguments_and_groups()[source]
save_action(section, *args, **kwargs)[source]
planemo.autopygen.source_file_parsing.decoy_parser.obtain_class_def() ClassDef | None[source]

planemo.autopygen.source_file_parsing.local_module_parsing module

Module responsible for resolving assignments and constant list comprehensives used in argument parser

class planemo.autopygen.source_file_parsing.local_module_parsing.UnknownNamesRemoval(unknown: Set[str])[source]

Bases: NodeVisitor

Removes unknown names that can’t be resolved and replaces them with a constant string that can be detected by linter

Attributes —

unknown: Set[str]

set of names that represent variables used in parser initialization, that have not been resolved yet

visit_ClassDef(node: ClassDef) Any[source]
visit_Name(node: Name) Any[source]
planemo.autopygen.source_file_parsing.local_module_parsing.handle_local_module_names(actions: List[stmt], unknown_names: Set[str]) Module[source]

Function used to remove assignments and list comprehensions which can’t be resolved

Parameters

actions: List[ast.stmt]

list of actions extracted so far

unknown_names:

set of unknown names that have to be extracted

Returns

Python module containing assignments and list comprehensions whose values are based on constants.py

planemo.autopygen.source_file_parsing.parser_discovery_and_init module

Module responsible for discovery of import statements importing Argument parser and discovery of the statements initializing the parser itself

class planemo.autopygen.source_file_parsing.parser_discovery_and_init.ArgumentCreationDiscovery(actions: List[stmt], main_name: str)[source]

Bases: Discovery

Class responsible for extraction of statements which initialize the input arguments. It is able to extract function calls on the original parser, and on the argument groups extracted by GroupDiscovery

static is_call_on_parser_or_group(node: Call)[source]
report_findings() Tuple[List[stmt]][source]
visit_Call(node: Call) Any[source]
class planemo.autopygen.source_file_parsing.parser_discovery_and_init.GroupAndSubparsersDiscovery(actions: List[stmt], known_names: Set[str], main_name: str)[source]

Bases: Discovery

Class responsible for discovery of statements that initialize argument groups and subparsers

report_findings() Tuple[source]
visit_Assign(node: Assign)[source]
class planemo.autopygen.source_file_parsing.parser_discovery_and_init.ImportDiscovery(actions: List[stmt])[source]

Bases: Discovery

Class responsible for discovery and extraction of import statements

report_findings() Tuple[List[stmt], str | None, str | None, Set[str]][source]
visit_Import(node: Import) Any[source]
visit_ImportFrom(node: ImportFrom) Any[source]
class planemo.autopygen.source_file_parsing.parser_discovery_and_init.SimpleParserDiscoveryAndReplacement(actions: List[stmt], argparse_alias: str, argument_parser_alias: str, custom_parser_def: ClassDef)[source]

Bases: Discovery

Class responsible for discovery of ArgumentParser creation and assignment, and replacement of the class definition by the one supplied through constructor

static imported_using_from(node: Assign, argument_parser_alias: str)[source]
static imported_using_import(node: Assign, argparse_module_alias: str)[source]
static is_simple_assignment(node: Assign)[source]
report_findings() Tuple[source]
visit_Assign(node: Assign)[source]
planemo.autopygen.source_file_parsing.parser_discovery_and_init.get_parser_init_and_actions(source: Module) Tuple[List[stmt], str, Set[str]][source]
Function used to extract necessary imports, parser and argument creation

function calls

Parameters

sourceast.Module

source file parsed into ATT

Returns

List of extracted AST nodes, the main name of the parser and a set of section names

planemo.autopygen.source_file_parsing.parser_discovery_and_init.is_this_x_creation(node: Assign, function_name: str)[source]

planemo.autopygen.source_file_parsing.parsing_commons module

Module containing the parent class of Dicovery classes

class planemo.autopygen.source_file_parsing.parsing_commons.CustomAST(*args: Any, **kwargs: Any)[source]

Bases: stmt

class planemo.autopygen.source_file_parsing.parsing_commons.CustomVisitor[source]

Bases: NodeVisitor, ABC

abstractmethod report_findings() Tuple[source]
visit_and_report(source: Module)[source]
class planemo.autopygen.source_file_parsing.parsing_commons.Discovery(actions: List[stmt])[source]

Bases: CustomVisitor, ABC

planemo.autopygen.source_file_parsing.parsing_commons.add_parents(tree)[source]
planemo.autopygen.source_file_parsing.parsing_commons.create_module_tree_from_path(path: str) Module[source]
planemo.autopygen.source_file_parsing.parsing_commons.create_module_tree_from_str(text: str) Module[source]

planemo.autopygen.source_file_parsing.parsing_exceptions module

Module containing Exceptions that can be raised during param discovery

exception planemo.autopygen.source_file_parsing.parsing_exceptions.ArgParseImportNotFound[source]

Bases: ArgumentParsingDiscoveryError

Exception raised in case ArgParser was not imported

exception planemo.autopygen.source_file_parsing.parsing_exceptions.ArgParserNotUsed[source]

Bases: ArgumentParsingDiscoveryError

Exception raised in case no uses of argument parser were found

exception planemo.autopygen.source_file_parsing.parsing_exceptions.ArgumentParsingDiscoveryError[source]

Bases: Exception

Exception for general error encountered during param extraction

exception planemo.autopygen.source_file_parsing.parsing_exceptions.CouldNotFixNameError[source]

Bases: ArgumentParsingDiscoveryError

planemo.autopygen.source_file_parsing.unknown_names_discovery module

Module containing discovery classes used to find names (assignments to variables) that have not been extracted yet

class planemo.autopygen.source_file_parsing.unknown_names_discovery.UnknownNameInit(unknown_names: Set[str])[source]

Bases: CustomVisitor

Class used to initialize unknown names

report_findings() Tuple[source]
visit_Assign(node: Assign) Any[source]
visit_ClassDef(node: ClassDef) Any[source]
class planemo.autopygen.source_file_parsing.unknown_names_discovery.UnknownNamesDiscovery(known_names: Set[str])[source]

Bases: CustomVisitor

Discovery class used to find names that have not been initialized yet but are necessary for correct argument parser init

report_findings() Tuple[source]
visit_ClassDef(node: ClassDef) Any[source]
visit_ListComp(node: ListComp) Any[source]
visit_Name(node: Name) Any[source]
planemo.autopygen.source_file_parsing.unknown_names_discovery.initialize_variables_in_module(original_module: Module, parser_name: str, actions: List[stmt], imported_names: Set[str]) Tuple[List[stmt], Set[str]][source]

Function used to initialize variables that have constant values

Parameters

original_moduleast.Module

AST of the original source file

parser_namestr

default name of the parser

actionsList[ast.stmt]

list of actions extracted so far

imported_namesSet[str]

list of names imported from modules

Returns

List containing newly extracted actions and new unknown names

Module contents

Subpackage containing functions used for parameter extraction from source files