def add_config_dependency(self, dependent: SectionPathLike, depends_on: SectionPathLike, force_update: bool = False): from pyfileconf.sectionpath.sectionpath import SectionPath dependent_section_path = SectionPath.from_ambiguous(dependent) depends_on_section_path_str = SectionPath.from_ambiguous( depends_on).path_str if dependent_section_path.path_str == depends_on_section_path_str: # Will hit here while running an item, as it gets itself while running # No need to make config dependent on itself return self.config_dependencies[depends_on_section_path_str].add( dependent_section_path) if force_update: self.force_update_dependencies[depends_on_section_path_str].add( dependent_section_path)
def reset(self, section_path_strs: Iterable[str]): from pyfileconf.main import PipelineManager for sp_str in section_path_strs: sp = SectionPath.from_ambiguous( sp_str, base_section_path_str=self.base_section_path_str, strip_manager_from_iv=self.strip_manager_from_iv) pm = PipelineManager.get_manager_by_section_path_str(sp.path_str) relative_section_path_str = SectionPath(".".join(sp[1:])).path_str pm.reset(relative_section_path_str)
def __init__( self, section_path: SectionPathLike, action: PyfileconfActions, file_path: Optional[str] = None, ): from pyfileconf.sectionpath.sectionpath import SectionPath self.section_path = SectionPath.from_ambiguous(section_path) self.action = action self.file_path = file_path
def update(self, updates: Iterable[Dict[str, Any]]) -> None: """ :param updates: list of kwarg dictionaries which would normally be provided to .update_batch :return: """ from pyfileconf.main import PipelineManager updates_lol = manager.plm.hook.pyfileconf_pre_update_batch( pm=self, updates=updates) all_updates = itertools.chain(*updates_lol) for update in all_updates: sp = SectionPath.from_ambiguous( update['section_path_str'], base_section_path_str=self.base_section_path_str, strip_manager_from_iv=self.strip_manager_from_iv) pm = PipelineManager.get_manager_by_section_path_str(sp.path_str) relative_section_path_str = SectionPath(".".join(sp[1:])).path_str new_update = { **update, 'section_path_str': relative_section_path_str } pm._update(**new_update) # type: ignore manager.plm.hook.pyfileconf_post_update_batch(pm=self, updates=updates)