1
0
mirror of https://github.com/deadc0de6/dotdrop.git synced 2026-02-04 20:19:46 +00:00

remove ignore from templategen

This commit is contained in:
deadc0de6
2023-05-15 22:30:44 +02:00
committed by deadc0de
parent 29351a82b1
commit 83b7965207
3 changed files with 8 additions and 20 deletions

View File

@@ -143,7 +143,6 @@ def _dotfile_compare(opts, dotfile, tmp):
insttmp = None
if dotfile.template and \
Templategen.path_is_template(src,
ignore=ignores,
debug=opts.debug):
# install dotfile to temporary dir for compare
ret, err, insttmp = inst.install_to_temp(templ, tmp, src, dotfile.dst,
@@ -220,7 +219,6 @@ def _dotfile_install(opts, dotfile, tmpdir=None):
is_template = dotfile.template and Templategen.path_is_template(
dotfile.src,
ignore=ignores,
)
if hasattr(dotfile, 'link') and dotfile.link in (
LinkTypes.LINK, LinkTypes.LINK_CHILDREN,
@@ -244,10 +242,7 @@ def _dotfile_install(opts, dotfile, tmpdir=None):
return False, dotfile.key, None
src = tmp
# make sure to re-evaluate if is template
is_template = dotfile.template and Templategen.path_is_template(
src,
ignore=ignores,
)
is_template = dotfile.template and Templategen.path_is_template(src)
ret, err = inst.install(templ, src, dotfile.dst,
LinkTypes.NOLINK,
actionexec=pre_actions_exec,

View File

@@ -264,7 +264,7 @@ class Templategen:
return data.decode('utf-8', 'replace')
@staticmethod
def path_is_template(path, ignore=None, debug=False):
def path_is_template(path, debug=False):
"""recursively check if any file is a template within path"""
if debug:
LOG.dbg(f'is template: {path}', force=True)
@@ -274,13 +274,9 @@ class Templategen:
# does not exist
return False
if utils.must_ignore([path], ignore, debug=debug):
# must be ignored
return False
if os.path.isfile(path):
# is file
return Templategen._is_template(path, ignore=ignore, debug=debug)
return Templategen._is_template(path, debug=debug)
# is a directory
for entry in os.listdir(path):
@@ -288,13 +284,11 @@ class Templategen:
if not os.path.isfile(fpath):
# recursively explore directory
if Templategen.path_is_template(fpath,
ignore=ignore,
debug=debug):
return True
else:
# check if file is a template
if Templategen._is_template(fpath,
ignore=ignore,
debug=debug):
return True
return False
@@ -327,10 +321,10 @@ class Templategen:
return False
@staticmethod
def _is_template(path, ignore, debug=False):
def _is_template(path, debug=False):
"""test if file pointed by path is a template"""
if utils.must_ignore([path], ignore, debug=debug):
return False
if debug:
Logger().dbg(f'is template: {path}')
if not os.path.isfile(path):
return False
if os.stat(path).st_size == 0:

View File

@@ -169,9 +169,8 @@ class Updater:
return None
return tmp
def _is_template(self, path, ignores):
def _is_template(self, path):
if not Templategen.path_is_template(path,
ignore=ignores,
debug=self.debug):
self.log.dbg(f'{path} is NO template')
return False
@@ -222,7 +221,7 @@ class Updater:
self.log.sub(f'\"{local_path}\" ignored')
return True
self.log.dbg(f'update for file {deployed_path} and {local_path}')
if self._is_template(local_path, ignores):
if self._is_template(local_path):
# dotfile is a template
self.log.dbg(f'{local_path} is a template')
if self.showpatch: