mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-12 04:49:00 +00:00
refactoring
This commit is contained in:
@@ -126,7 +126,8 @@ class Cfg:
|
|||||||
def eval_dotfiles(self, profile, variables, debug=False):
|
def eval_dotfiles(self, profile, variables, debug=False):
|
||||||
"""resolve dotfiles src/dst/actions templating for this profile"""
|
"""resolve dotfiles src/dst/actions templating for this profile"""
|
||||||
t = Templategen(variables=variables)
|
t = Templategen(variables=variables)
|
||||||
for d in self.get_dotfiles(profile):
|
dotfiles = self._get_dotfiles(profile)
|
||||||
|
for d in dotfiles:
|
||||||
# src and dst path
|
# src and dst path
|
||||||
d.src = t.generate_string(d.src)
|
d.src = t.generate_string(d.src)
|
||||||
d.dst = t.generate_string(d.dst)
|
d.dst = t.generate_string(d.dst)
|
||||||
@@ -138,7 +139,7 @@ class Cfg:
|
|||||||
if self.key_actions_post in d.actions:
|
if self.key_actions_post in d.actions:
|
||||||
for action in d.actions[self.key_actions_post]:
|
for action in d.actions[self.key_actions_post]:
|
||||||
action.action = t.generate_string(action.action)
|
action.action = t.generate_string(action.action)
|
||||||
return self.get_dotfiles(profile)
|
return dotfiles
|
||||||
|
|
||||||
def _load_file(self):
|
def _load_file(self):
|
||||||
"""load the yaml file"""
|
"""load the yaml file"""
|
||||||
@@ -611,7 +612,7 @@ class Cfg:
|
|||||||
|
|
||||||
return True, dotfile
|
return True, dotfile
|
||||||
|
|
||||||
def get_dotfiles(self, profile):
|
def _get_dotfiles(self, profile):
|
||||||
"""return a list of dotfiles for a specific profile"""
|
"""return a list of dotfiles for a specific profile"""
|
||||||
if profile not in self.prodots:
|
if profile not in self.prodots:
|
||||||
return []
|
return []
|
||||||
|
|||||||
@@ -94,10 +94,10 @@ class TestConfig(unittest.TestCase):
|
|||||||
self.assertTrue(pf2key in profiles)
|
self.assertTrue(pf2key in profiles)
|
||||||
|
|
||||||
# test dotfiles
|
# test dotfiles
|
||||||
dotfiles = conf.get_dotfiles(pf1key)
|
dotfiles = conf._get_dotfiles(pf1key)
|
||||||
self.assertTrue(df1key in [x.key for x in dotfiles])
|
self.assertTrue(df1key in [x.key for x in dotfiles])
|
||||||
self.assertTrue(df2key in [x.key for x in dotfiles])
|
self.assertTrue(df2key in [x.key for x in dotfiles])
|
||||||
dotfiles = conf.get_dotfiles(pf2key)
|
dotfiles = conf._get_dotfiles(pf2key)
|
||||||
self.assertTrue(df1key in [x.key for x in dotfiles])
|
self.assertTrue(df1key in [x.key for x in dotfiles])
|
||||||
self.assertFalse(df2key in [x.key for x in dotfiles])
|
self.assertFalse(df2key in [x.key for x in dotfiles])
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user