pyfileconf.io.file.load.parsers package

Submodules

pyfileconf.io.file.load.parsers.assign module

class pyfileconf.io.file.load.parsers.assign.AssignmentByVarnameExtractor(varname)[source]

Bases: pyfileconf.io.file.load.parsers.assign.AssignmentExtractor

__init__(varname)[source]

Initialize self. See help(type(self)) for accurate signature.

visit_AnnAssign(node)[source]
visit_Assign(node)[source]
class pyfileconf.io.file.load.parsers.assign.AssignmentExtractor[source]

Bases: ast.NodeVisitor

__init__()[source]

Initialize self. See help(type(self)) for accurate signature.

visit_AnnAssign(node)[source]
visit_Assign(node)[source]
pyfileconf.io.file.load.parsers.assign.extract_assignment_from_ast(module)[source]
Return type

Optional[ForwardRef]

pyfileconf.io.file.load.parsers.assign.extract_assignment_from_ast_by_name(module, name)[source]
Return type

Optional[ForwardRef]

pyfileconf.io.file.load.parsers.assign.extract_assignments_from_ast(module)[source]
Return type

AssignmentStatementContainer

pyfileconf.io.file.load.parsers.assign.extract_assignments_from_ast_by_name(module, name)[source]
Return type

AssignmentStatementContainer

pyfileconf.io.file.load.parsers.base module

class pyfileconf.io.file.load.parsers.base.FileParser(filepath)[source]

Bases: object

__init__(filepath)[source]

Initialize self. See help(type(self)) for accurate signature.

load()[source]
Return type

List[str]

pyfileconf.io.file.load.parsers.collections module

class pyfileconf.io.file.load.parsers.collections.AstDictListConverter(convert_str_values=False)[source]

Bases: ast.NodeVisitor

__init__(convert_str_values=False)[source]

Initialize self. See help(type(self)) for accurate signature.

visit_Dict(node)[source]
visit_List(node)[source]
pyfileconf.io.file.load.parsers.collections.extract_collection_from_ast(ast_node, convert_str_values=False)[source]
Return type

Union[dict, list, None]

pyfileconf.io.file.load.parsers.collections.extract_collections_from_ast(ast_node, convert_str_values=False)[source]

returns a list of dicts or lists. Goes through ast, converting ast.Dict to dict and ast.List to list, leaving the rest intact. Returns a list of these created dicts and lists

Args:

ast_node:

Returns:

Return type

List[Union[dict, list]]

pyfileconf.io.file.load.parsers.extname module

class pyfileconf.io.file.load.parsers.extname.NameExtractor[source]

Bases: ast.NodeVisitor

__init__()[source]

Initialize self. See help(type(self)) for accurate signature.

visit_Name(node)[source]
pyfileconf.io.file.load.parsers.extname.extract_external_name_from_assign_value(ast_node)[source]

Identifies the root part of an assignment value, so long as it is not builtin.

Examples from a import b

b -> ‘b’ b.attr -> ‘b’

import c

c.test -> ‘c’ c.thing.stuff -> ‘c’

‘abc’ -> None 123 -> None

Args:

ast_node: should be ast form of the value of an assignment

Returns:

Return type

Optional[str]

pyfileconf.io.file.load.parsers.extname.extract_unique_external_names_from_assign_value(ast_node)[source]

Same as extract_external_name_from_assign_value but returns a list always, can return multiple names, and drops duplicates in the returned names

Return type

List[str]

pyfileconf.io.file.load.parsers.fromdict module

pyfileconf.io.file.load.parsers.fromdict.extract_dict_from_ast_dict_or_dict_constructor(ast_dict)[source]
Return type

dict

pyfileconf.io.file.load.parsers.funcdef module

class pyfileconf.io.file.load.parsers.funcdef.FunctionDefinitionByNameExtractor(func_name)[source]

Bases: pyfileconf.io.file.load.parsers.funcdef.FunctionDefinitionExtractor

__init__(func_name)[source]

Initialize self. See help(type(self)) for accurate signature.

visit_FunctionDef(node)[source]
class pyfileconf.io.file.load.parsers.funcdef.FunctionDefinitionExtractor[source]

Bases: ast.NodeVisitor

__init__()[source]

Initialize self. See help(type(self)) for accurate signature.

visit_ClassDef(node)[source]
visit_FunctionDef(node)[source]
class pyfileconf.io.file.load.parsers.funcdef.FunctionDefinitionOrClassInitByNameExtractor(func_name)[source]

Bases: pyfileconf.io.file.load.parsers.funcdef.FunctionDefinitionByNameExtractor

visit_ClassDef(node)[source]
pyfileconf.io.file.load.parsers.funcdef.extract_function_definition_from_ast_by_name(module, name)[source]
Return type

Optional[FunctionDef]

pyfileconf.io.file.load.parsers.funcdef.extract_function_definition_or_class_init_from_ast_by_name(module, name)[source]
Return type

Optional[FunctionDef]

pyfileconf.io.file.load.parsers.funcdef.extract_function_definitions_from_ast(module)[source]
Return type

List[FunctionDef]

pyfileconf.io.file.load.parsers.funcdef.extract_function_definitions_from_ast_by_name(module, name)[source]
Return type

List[FunctionDef]

pyfileconf.io.file.load.parsers.funcdef.extract_function_definitions_or_class_inits_from_ast_by_name(module, name)[source]
Return type

List[FunctionDef]

pyfileconf.io.file.load.parsers.imp module

class pyfileconf.io.file.load.parsers.imp.ImportExtractor[source]

Bases: ast.NodeVisitor

__init__()[source]

Initialize self. See help(type(self)) for accurate signature.

visit_Import(node)[source]
visit_ImportFrom(node)[source]
pyfileconf.io.file.load.parsers.imp.extract_imports_from_ast(module)[source]
Return type

ImportStatementContainer

pyfileconf.io.file.load.parsers.imp.extract_module_import_from_ast(module)[source]
Return type

Optional[ModuleImportStatement]

pyfileconf.io.file.load.parsers.imp.extract_obj_import_from_ast(module)[source]
Return type

Optional[ObjectImportStatement]

pyfileconf.io.file.load.parsers.kwargs module

class pyfileconf.io.file.load.parsers.kwargs.KeywordByNameExtractor(name)[source]

Bases: pyfileconf.io.file.load.parsers.kwargs.KeywordExtractor

__init__(name)[source]

Initialize self. See help(type(self)) for accurate signature.

visit_keyword(node)[source]
class pyfileconf.io.file.load.parsers.kwargs.KeywordExtractor[source]

Bases: ast.NodeVisitor

__init__()[source]

Initialize self. See help(type(self)) for accurate signature.

visit_keyword(node)[source]
pyfileconf.io.file.load.parsers.kwargs.extract_keywords_from_ast(node)[source]
Return type

dict

pyfileconf.io.file.load.parsers.kwargs.extract_keywords_from_ast_by_name(node, name)[source]
Return type

dict

pyfileconf.io.file.load.parsers.py module

class pyfileconf.io.file.load.parsers.py.PythonFileParser(filepath)[source]

Bases: pyfileconf.io.file.load.parsers.base.FileParser

load()[source]
Return type

Tuple[Module, List[str]]