[docs]@dataclassclassDistManagerFactory(object):"""Creates instances of :class:`.DistManager`. """path:Path=field()"""The path to the YAML application configuration file."""@property@persisted('_config')defconfig(self)->AppConfig:returnNoneifself.pathisNoneelseAppConfig(self.path)def__call__(self,**kwargs)->DistManager:params=dict(kwargs)params['config']=self.configreturnDistManager(**params)
[docs]@dataclassclassApplication(object):"""Application base class. """CLASS_INSPECTOR={}CLI_META={'option_excludes':{'dist_mng_factory'},'option_overrides':{'repo_pref':{'short_name':'r'}}}dist_mng_factory:DistManagerFactory=field()"""The main class that freezes/thaws and provides repo information."""def__post_init__(self):self._params:Dict[str,Any]={}@property@persisted('_dist_mng')defdist_mng(self)->DistManager:iflogger.isEnabledFor(logging.DEBUG):logger.debug(f'params: {self._params}')returnself.dist_mng_factory(**self._params)
[docs]@dataclassclassInfoApplication(Application):"""Captures and syncronizes a user home and its Git repositories with other hosts. """CLI_META=ActionCliManager.combine_meta(Application,{'option_excludes':{'log_config'},'mnemonic_overrides':{'list_profiles':'profiles'}})log_config:LogConfigurator=field()"""The application log configurator."""profiles:str=field(default=None)"""Comma spearated list of profiles in config."""def__post_init__(self):super().__post_init__()ifself.profilesisnotNone:self._params['profiles']=AppConfig.split_profiles(self.profiles)self.log_config.level='err'self.log_config()
[docs]defrepoinfo(self,names:str=None):"""Get information on repositories. :param names: the last component of the repo's directory name """names:List[str]=NoneifnamesisNoneelsenames.split(',')self.dist_mng.print_repo_info(names)
[docs]defrepos(self,format:str='{path}'):"""Output all repository top level info. :param format: format string (ie {name}: {path}, remotes={remotes}, dirty={dirty}) """self.dist_mng.print_repos(format)
[docs]deflist_profiles(self):"""Print the profiles """config:AppConfig=self.dist_mng_factory.configprint('\n'.join(config.get_profiles()))
[docs]@dataclassclassModifyApplication(Application,metaclass=ABCMeta):"""Super class for applications that modify the file system. """CLI_META=ActionCliManager.combine_meta(Application,{'option_overrides':{'dist_dir':{'metavar':'DIRECTORY','short_name':'d'},'dry_run':{'short_name':None},'profiles':{'short_name':'p'}}})dist_dir:Path=field(default=None)"""The location of build out distribution."""profiles:str=field(default=None)"""Comma spearated list of profiles in config."""dry_run:bool=field(default=False)"""Do not do anything, just act like it."""def__post_init__(self):super().__post_init__()forattrin'dist_dir profiles dry_run'.split():ifhasattr(self,attr):self._params[attr]=getattr(self,attr)
[docs]@dataclassclassTargetApplication(ModifyApplication,metaclass=ABCMeta):CLI_META=ActionCliManager.combine_meta(ModifyApplication,{'option_overrides':{'target_dir':{'metavar':'DIRECTORY','short_name':'t'}}})target_dir:Path=field(default=None)"""The location of build out target dir."""def__post_init__(self):super().__post_init__()ifself.target_dirisnotNone:self._params['target_dir']=self.target_dir
[docs]deffreeze(self,wheel_dep:Path=Path('zensols.grsync'),repo_pref:str=None):"""Create a distribution. :param whee_dep: used to create the wheel dep files :param repo_pref: the repository to make primary on thaw """self.dist_mng.freeze(wheel_dep)
[docs]defcopy(self,repo_pref:str=None):"""Build out a distribution. :param repo_pref: the repository to make primary on thaw """self.dst_mnt.copy()
[docs]defmove(self,move_dir:Path=None,dir_reduce:bool=False):"""Move a distribution to another root (easy to delete). :param move_dir: the location of build out move dir :param reduce: dir_remove empty directories """self.dst_mnt.move(move_dir,dir_reduce)