pygalgen.generator.common.source_file_parsing package¶
Subpackage containing functions used for parameter extraction from source files
Submodules¶
pygalgen.generator.common.source_file_parsing.local_module_parsing module¶
Module responsible for resolving assignments and constant list comprehensives used in argument parser
- class pygalgen.generator.common.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
- pygalgen.generator.common.source_file_parsing.local_module_parsing.handle_local_module_names(actions: List[AST], unknown_names: set[str]) Module [source]¶
Function used to remove assignments and list comprehensions which can’t be resolved
Parameters¶
- actionsList[ast.AST]
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
pygalgen.generator.common.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 pygalgen.generator.common.source_file_parsing.parser_discovery_and_init.ArgumentCreationDiscovery(actions: List[AST], main_name: str, groups: Set[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
- class pygalgen.generator.common.source_file_parsing.parser_discovery_and_init.GroupDiscovery(actions: List[AST], main_name: str)[source]¶
Bases:
Discovery
Class responsible for discovery of statements that initialize argument groups
- class pygalgen.generator.common.source_file_parsing.parser_discovery_and_init.ImportDiscovery(actions: List[AST])[source]¶
Bases:
Discovery
Class responsible for discovery and extraction of import statements
- class pygalgen.generator.common.source_file_parsing.parser_discovery_and_init.SimpleParserDiscoveryAndReplacement(actions: List[AST], argparse_alias: str | None, argument_parser_alias: str | None, 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
- pygalgen.generator.common.source_file_parsing.parser_discovery_and_init.get_parser_init_and_actions(source: Module) Tuple[List[AST], str, Set[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
pygalgen.generator.common.source_file_parsing.parsing_commons module¶
Module containing the parent class of Dicovery classes
- class pygalgen.generator.common.source_file_parsing.parsing_commons.CustomVisitor[source]¶
Bases:
NodeVisitor
,ABC
- class pygalgen.generator.common.source_file_parsing.parsing_commons.Discovery(actions: List[AST])[source]¶
Bases:
CustomVisitor
,ABC
pygalgen.generator.common.source_file_parsing.parsing_exceptions module¶
Module containing Exceptions that can be raised during param discovery
- exception pygalgen.generator.common.source_file_parsing.parsing_exceptions.ArgParseImportNotFound[source]¶
Bases:
ArgumentParsingDiscoveryError
Exception raised in case ArgParser was not imported
- exception pygalgen.generator.common.source_file_parsing.parsing_exceptions.ArgParserNotUsed[source]¶
Bases:
ArgumentParsingDiscoveryError
Exception raised in case no uses of argument parser were found
pygalgen.generator.common.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 pygalgen.generator.common.source_file_parsing.unknown_names_discovery.UnknownNameInit(unknown_names: Set[str])[source]¶
Bases:
CustomVisitor
Class used to initialize unknown names
- class pygalgen.generator.common.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
- pygalgen.generator.common.source_file_parsing.unknown_names_discovery.initialize_variables_in_module(original_module: Module, parser_name: str, sections: Set[str], actions: List[AST], imported_names: Set[str]) Tuple[List[AST], 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
- sectionsSet[str]
set of section names
- actionsList[ast.AST]
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