1
0
mirror of https://github.com/deadc0de6/dotdrop.git synced 2026-02-04 23:14:47 +00:00

adding notemplate config options

This commit is contained in:
deadc0de6
2020-10-08 19:42:04 +02:00
parent d9b3094294
commit a57496a9ba
3 changed files with 18 additions and 2 deletions

View File

@@ -58,6 +58,7 @@ class CfgYaml:
key_dotfile_actions = 'actions'
key_dotfile_link_children = 'link_children'
key_dotfile_noempty = 'ignoreempty'
key_dotfile_notemplate = 'notemplate'
# profile
key_profile_dotfiles = 'dotfiles'
@@ -83,6 +84,7 @@ class CfgYaml:
key_settings_noempty = Settings.key_ignoreempty
key_settings_minversion = Settings.key_minversion
key_imp_link = Settings.key_link_on_import
key_settings_notemplate = Settings.key_template_dotfile_default
# link values
lnk_nolink = LinkTypes.NOLINK.name.lower()
@@ -597,6 +599,10 @@ class CfgYaml:
if self.key_dotfile_noempty not in v:
val = self.settings.get(self.key_settings_noempty, False)
v[self.key_dotfile_noempty] = val
# apply notemplate if undefined
if self.key_dotfile_notemplate not in v:
val = self.settings.get(self.key_settings_notemplate, False)
v[self.key_dotfile_notemplate] = val
return new
def _add_variables(self, new, shell=False, template=True, prio=False):

View File

@@ -16,12 +16,13 @@ class Dotfile(DictParser):
key_noempty = 'ignoreempty'
key_trans_r = 'trans_read'
key_trans_w = 'trans_write'
key_notemplate = 'notemplate'
def __init__(self, key, dst, src,
actions=[], trans_r=None, trans_w=None,
link=LinkTypes.NOLINK, noempty=False,
cmpignore=[], upignore=[],
instignore=[]):
instignore=[], notemplate=False):
"""
constructor
@key: dotfile key
@@ -35,6 +36,7 @@ class Dotfile(DictParser):
@upignore: patterns to ignore when updating
@cmpignore: patterns to ignore when comparing
@instignore: patterns to ignore when installing
@notemplate: disable template for this dotfile
"""
self.actions = actions
self.dst = dst
@@ -47,6 +49,7 @@ class Dotfile(DictParser):
self.upignore = upignore
self.cmpignore = cmpignore
self.instignore = instignore
self.notemplate = notemplate
if self.link != LinkTypes.NOLINK and \
(
@@ -91,10 +94,12 @@ class Dotfile(DictParser):
value['noempty'] = value.get(cls.key_noempty, False)
value['trans_r'] = value.get(cls.key_trans_r)
value['trans_w'] = value.get(cls.key_trans_w)
value['notemplate'] = value.get(cls.key_notemplate, False)
# remove old entries
value.pop(cls.key_noempty, None)
value.pop(cls.key_trans_r, None)
value.pop(cls.key_trans_w, None)
value.pop(cls.key_notemplate, None)
return value
def __eq__(self, other):
@@ -114,6 +119,7 @@ class Dotfile(DictParser):
out += '\n{}src: \"{}\"'.format(indent, self.src)
out += '\n{}dst: \"{}\"'.format(indent, self.dst)
out += '\n{}link: \"{}\"'.format(indent, str(self.link))
out += '\n{}notemplate: \"{}\"'.format(indent, str(self.notemplate))
out += '\n{}pre-action:'.format(indent)
some = self.get_pre_actions()

View File

@@ -34,6 +34,7 @@ class Settings(DictParser):
key_func_file = 'func_file'
key_filter_file = 'filter_file'
key_diff_command = 'diff_command'
key_template_dotfile_default = 'template_dotfile_default'
# import keys
key_import_actions = 'import_actions'
@@ -49,7 +50,8 @@ class Settings(DictParser):
upignore=[], cmpignore=[], instignore=[],
workdir='~/.config/dotdrop', showdiff=False,
minversion=None, func_file=[], filter_file=[],
diff_command='diff -r -u {0} {1}'):
diff_command='diff -r -u {0} {1}',
template_dotfile_default=False):
self.backup = backup
self.banner = banner
self.create = create
@@ -72,6 +74,7 @@ class Settings(DictParser):
self.func_file = func_file
self.filter_file = filter_file
self.diff_command = diff_command
self.template_dotfile_default = template_dotfile_default
def _serialize_seq(self, name, dic):
"""serialize attribute 'name' into 'dic'"""
@@ -94,6 +97,7 @@ class Settings(DictParser):
self.key_workdir: self.workdir,
self.key_minversion: self.minversion,
self.key_diff_command: self.diff_command,
self.key_template_dotfile_default: self.template_dotfile_default,
}
self._serialize_seq(self.key_default_actions, dic)
self._serialize_seq(self.key_import_actions, dic)