mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-16 19:05:16 +00:00
Fixing conflicts with master
This commit is contained in:
@@ -42,6 +42,9 @@ class Cfg:
|
|||||||
# import keys
|
# import keys
|
||||||
key_import_vars = 'import_variables'
|
key_import_vars = 'import_variables'
|
||||||
key_import_actions = 'import_actions'
|
key_import_actions = 'import_actions'
|
||||||
|
key_cmpignore = 'cmpignore'
|
||||||
|
key_upignore = 'upignore'
|
||||||
|
|
||||||
key_import_configs = 'import_configs'
|
key_import_configs = 'import_configs'
|
||||||
|
|
||||||
# actions keys
|
# actions keys
|
||||||
@@ -146,6 +149,11 @@ class Cfg:
|
|||||||
self.ext_variables = {}
|
self.ext_variables = {}
|
||||||
self.ext_dynvariables = {}
|
self.ext_dynvariables = {}
|
||||||
|
|
||||||
|
# cmpignore patterns
|
||||||
|
self.cmpignores = []
|
||||||
|
# upignore patterns
|
||||||
|
self.upignores = []
|
||||||
|
|
||||||
if not self._load_config(profile=profile):
|
if not self._load_config(profile=profile):
|
||||||
raise ValueError('config is not valid')
|
raise ValueError('config is not valid')
|
||||||
|
|
||||||
@@ -251,6 +259,14 @@ class Cfg:
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
# load global upignore
|
||||||
|
if self.key_upignore in self.lnk_settings:
|
||||||
|
self.upignores = self.lnk_settings[self.key_upignore] or []
|
||||||
|
|
||||||
|
# load global cmpignore
|
||||||
|
if self.key_cmpignore in self.lnk_settings:
|
||||||
|
self.cmpignores = self.lnk_settings[self.key_cmpignore] or []
|
||||||
|
|
||||||
# parse external actions
|
# parse external actions
|
||||||
try:
|
try:
|
||||||
ext_actions = self.lnk_settings[self.key_import_actions] or ()
|
ext_actions = self.lnk_settings[self.key_import_actions] or ()
|
||||||
@@ -367,7 +383,12 @@ class Cfg:
|
|||||||
|
|
||||||
# parse actions
|
# parse actions
|
||||||
itsactions = v.get(self.key_dotfiles_actions, [])
|
itsactions = v.get(self.key_dotfiles_actions, [])
|
||||||
actions = self._parse_actions(itsactions)
|
actions = self._parse_actions(itsactions, profile=profile)
|
||||||
|
if self.debug:
|
||||||
|
self.log.dbg('action for {}'.format(k))
|
||||||
|
for t in [self.key_actions_pre, self.key_actions_post]:
|
||||||
|
for action in actions[t]:
|
||||||
|
self.log.dbg('- {}: {}'.format(t, action))
|
||||||
|
|
||||||
# parse read transformation
|
# parse read transformation
|
||||||
itstrans_r = v.get(self.key_dotfiles_trans_r)
|
itstrans_r = v.get(self.key_dotfiles_trans_r)
|
||||||
@@ -413,9 +434,11 @@ class Cfg:
|
|||||||
|
|
||||||
# parse cmpignore pattern
|
# parse cmpignore pattern
|
||||||
cmpignores = v.get(self.key_dotfiles_cmpignore, [])
|
cmpignores = v.get(self.key_dotfiles_cmpignore, [])
|
||||||
|
cmpignores.extend(self.cmpignores)
|
||||||
|
|
||||||
# parse upignore pattern
|
# parse upignore pattern
|
||||||
upignores = v.get(self.key_dotfiles_upignore, [])
|
upignores = v.get(self.key_dotfiles_upignore, [])
|
||||||
|
upignores.extend(self.upignores)
|
||||||
|
|
||||||
# create new dotfile
|
# create new dotfile
|
||||||
self.dotfiles[k] = Dotfile(k, dst, src,
|
self.dotfiles[k] = Dotfile(k, dst, src,
|
||||||
@@ -697,19 +720,25 @@ class Cfg:
|
|||||||
dotfiles.extend(self.prodots[other])
|
dotfiles.extend(self.prodots[other])
|
||||||
return True, dotfiles
|
return True, dotfiles
|
||||||
|
|
||||||
def _parse_actions(self, entries):
|
def _parse_actions(self, entries, profile=None):
|
||||||
"""parse actions specified for an element
|
"""parse actions specified for an element
|
||||||
where entries are the ones defined for this dotfile"""
|
where entries are the ones defined for this dotfile"""
|
||||||
res = {
|
res = {
|
||||||
self.key_actions_pre: [],
|
self.key_actions_pre: [],
|
||||||
self.key_actions_post: [],
|
self.key_actions_post: [],
|
||||||
}
|
}
|
||||||
|
vars = self.get_variables(profile, debug=self.debug)
|
||||||
|
t = Templategen(variables=vars)
|
||||||
for line in entries:
|
for line in entries:
|
||||||
fields = shlex.split(line)
|
fields = shlex.split(line)
|
||||||
entry = fields[0]
|
entry = fields[0]
|
||||||
args = []
|
args = []
|
||||||
if len(fields) > 1:
|
if len(fields) > 1:
|
||||||
args = fields[1:]
|
tmpargs = fields[1:]
|
||||||
|
args = []
|
||||||
|
# template args
|
||||||
|
for arg in tmpargs:
|
||||||
|
args.append(t.generate_string(arg))
|
||||||
action = None
|
action = None
|
||||||
if self.key_actions_pre in self.actions and \
|
if self.key_actions_pre in self.actions and \
|
||||||
entry in self.actions[self.key_actions_pre]:
|
entry in self.actions[self.key_actions_pre]:
|
||||||
|
|||||||
Reference in New Issue
Block a user