diff --git a/dotdrop/config.py b/dotdrop/config.py index ff0ff04..9d0d2ad 100644 --- a/dotdrop/config.py +++ b/dotdrop/config.py @@ -18,6 +18,7 @@ class Cfg: key_config = 'config' key_dotfiles = 'dotfiles' key_actions = 'actions' + key_trans = 'trans' key_dotpath = 'dotpath' key_profiles = 'profiles' key_profiles_dots = 'dotfiles' @@ -26,6 +27,7 @@ class Cfg: key_dotfiles_dst = 'dst' key_dotfiles_link = 'link' key_dotfiles_actions = 'actions' + key_dotfiles_trans = 'trans' def __init__(self, cfgpath): if not os.path.exists(cfgpath): @@ -41,6 +43,8 @@ class Cfg: # not linked to content self.actions = {} # not linked to content + self.trans = {} + # not linked to content self.prodots = {} if not self._load_file(): raise ValueError('config is not valid') @@ -94,6 +98,12 @@ class Cfg: for k, v in self.content[self.key_actions].items(): self.actions[k] = Action(k, v) + # parse all transformations + if self.key_trans in self.content: + if self.content[self.key_trans] is not None: + for k, v in self.content[self.key_trans].items(): + self.trans[k] = Action(k, v) + # parse the profiles self.profiles = self.content[self.key_profiles] if self.profiles is None: @@ -117,8 +127,12 @@ class Cfg: entries = v[self.key_dotfiles_actions] if \ self.key_dotfiles_actions in v else [] actions = self._parse_actions(self.actions, entries) + entries = v[self.key_dotfiles_trans] if \ + self.key_dotfiles_trans in v else [] + trans = self._parse_actions(self.trans, entries) self.dotfiles[k] = Dotfile(k, dst, src, - link=link, actions=actions) + link=link, actions=actions + trans=trans) # assign dotfiles to each profile for k, v in self.profiles.items(): diff --git a/dotdrop/dotfile.py b/dotdrop/dotfile.py index 3a3c75b..657385b 100644 --- a/dotdrop/dotfile.py +++ b/dotdrop/dotfile.py @@ -7,7 +7,8 @@ represents a dotfile in dotdrop class Dotfile: - def __init__(self, key, dst, src, actions=[], link=False): + def __init__(self, key, dst, src, + actions=[], trans=[], link=False): # key of dotfile in the config self.key = key # where to install this dotfile @@ -18,6 +19,8 @@ class Dotfile: self.link = link # list of actions self.actions = actions + # list of transformations + self.trans = trans def __str__(self): return 'key:%s, src: %s, dst: %s, link: %s' % (self.key, self.src,