pyfileconf.basemodels package

Submodules

pyfileconf.basemodels.collection module

pyfileconf.basemodels.collection.to_nested_dict(collection)[source]

pyfileconf.basemodels.config module

class pyfileconf.basemodels.config.ConfigBase(d=None, name=None, annotations=None, imports=None, _file=None, begin_assignments=None, klass=None, always_import_strs=None, always_assign_strs=None, **kwargs)[source]

Bases: dict

__init__(d=None, name=None, annotations=None, imports=None, _file=None, begin_assignments=None, klass=None, always_import_strs=None, always_assign_strs=None, **kwargs)[source]

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

as_imports_and_assignments()[source]
Return type

Tuple[ImportStatementContainer, AssignmentStatementContainer]

change_from_refresh()[source]

Determines whether refresh would actually cause a change in the config and returns a dictionary of what would be updated

Return type

Dict[str, Any]

Returns

the new config dict that would apply while calling .refresh if it would be updated, otherwise an empty dict

config_file_class

alias of pyfileconf.basemodels.file.ConfigFileBase

copy() → a shallow copy of D[source]
classmethod from_file(filepath, name=None, klass=None, always_import_strs=None, always_assign_strs=None)[source]
refresh()[source]

Reloads from the existing, then re-applies any config updates. Useful for when this config depends on the attribute of some other config which was updated. :rtype: Dict[str, Any] :return: The updates made to the config

to_file(filepath)[source]
update(E=None, pyfileconf_persist=True, **F)[source]

If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

would_update(E=None, **F)[source]

Determines whether updates would actually cause a change in the config

Parameters
  • E – dictionary of updates

  • F – kwargs of updates

Return type

bool

Returns

whether config would actually change when calling .update with the same arguments

pyfileconf.basemodels.container module

class pyfileconf.basemodels.container.Container[source]

Bases: object

add_if_missing(item)[source]

Checks if item is in container. If so, doesn’t do anything.

Assuming item is not in container, checks for prefer_beginning attribute of item. If True, insert at position 0. If False, or doesn’t have attr, append to end.

append(item)[source]
append_if_missing(item)[source]
copy()[source]
extend(items)[source]
insert(index, item)[source]
insert_if_missing(index, item)[source]
items: List[Any] = []

pyfileconf.basemodels.file module

class pyfileconf.basemodels.file.ConfigFileBase(filepath, name=None, klass=None, always_import_strs=None, always_assign_strs=None)[source]

Bases: object

__init__(filepath, name=None, klass=None, always_import_strs=None, always_assign_strs=None)[source]

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

always_assign_with_names_dict: Dict[str, List[pyfileconf.assignments.models.statement.AssignmentStatement]] = {}
always_assigns: List[pyfileconf.assignments.models.statement.AssignmentStatement] = []
always_imports: List[Union[pyfileconf.imports.models.statements.module.ModuleImportStatement, pyfileconf.imports.models.statements.obj.ObjectImportStatement]] = []
load(config_class=None)[source]
Return type

ConfigBase

save(config)[source]
Return type

None

pyfileconf.basemodels.registrar module