1
0
mirror of https://github.com/deadc0de6/dotdrop.git synced 2026-02-16 11:11:10 +00:00
This commit is contained in:
user
2025-05-14 22:03:18 +02:00
parent 8dc1af6cd2
commit 00218887ae
4 changed files with 36 additions and 29 deletions

View File

@@ -244,7 +244,7 @@ def _dotfile_install(opts, dotfile, tmpdir=None):
is_template=is_template, is_template=is_template,
ignore=ignores, ignore=ignores,
chmod=dotfile.chmod, chmod=dotfile.chmod,
handle_dir_as_block=asblock, dir_as_block=asblock,
) )
else: else:
# nolink # nolink
@@ -271,7 +271,7 @@ def _dotfile_install(opts, dotfile, tmpdir=None):
ignore=ignores, ignore=ignores,
is_template=is_template, is_template=is_template,
chmod=dotfile.chmod, chmod=dotfile.chmod,
handle_dir_as_block=asblock, dir_as_block=asblock,
) )
if tmp: if tmp:
tmp = os.path.join(opts.dotpath, tmp) tmp = os.path.join(opts.dotpath, tmp)

View File

@@ -99,7 +99,8 @@ class Dotfile(DictParser):
"""patch dict""" """patch dict"""
value['noempty'] = value.get(cls.key_noempty, False) value['noempty'] = value.get(cls.key_noempty, False)
value['template'] = value.get(cls.key_template, True) value['template'] = value.get(cls.key_template, True)
value['handle_dir_as_block'] = value.get(cls.key_handle_dir_as_block, False) value['handle_dir_as_block'] = value.get(
cls.key_handle_dir_as_block, False)
# remove old entries # remove old entries
value.pop(cls.key_noempty, None) value.pop(cls.key_noempty, None)
return value return value
@@ -143,7 +144,8 @@ class Dotfile(DictParser):
else: else:
out += f'\n{indent}chmod: \"{self.chmod}\"' out += f'\n{indent}chmod: \"{self.chmod}\"'
if self.handle_dir_as_block: if self.handle_dir_as_block:
out += f'\n{indent}handle_dir_as_block: \"{self.handle_dir_as_block}\"' out += (f'\n{indent}handle_dir_as_block: '
f'"{self.handle_dir_as_block}"')
out += f'\n{indent}pre-action:' out += f'\n{indent}pre-action:'
some = self.get_pre_actions() some = self.get_pre_actions()

View File

@@ -18,7 +18,8 @@ class FTreeDir:
directory tree for comparison directory tree for comparison
""" """
def __init__(self, path, ignores=None, debug=False, handle_dir_as_block=False): def __init__(self, path, ignores=None,
debug=False, handle_dir_as_block=False):
self.path = path self.path = path
self.ignores = ignores self.ignores = ignores
self.debug = debug self.debug = debug
@@ -34,9 +35,11 @@ class FTreeDir:
ignore empty directory ignore empty directory
test for ignore pattern test for ignore pattern
""" """
# if directory should be handled as a block, just add the directory itself # if directory should be handled as a block
# just add the directory itself
if self.handle_dir_as_block: if self.handle_dir_as_block:
self.log.dbg(f'handle as block: {self.path}') self.log.dbg(
f'handle as block: {self.path}')
self.entries.append(self.path) self.entries.append(self.path)
return return

View File

@@ -79,7 +79,7 @@ class Installer:
def install(self, templater, src, dst, linktype, def install(self, templater, src, dst, linktype,
actionexec=None, noempty=False, actionexec=None, noempty=False,
ignore=None, is_template=True, ignore=None, is_template=True,
chmod=None, handle_dir_as_block=False): chmod=None, dir_as_block=False):
""" """
install src to dst install src to dst
@@ -92,7 +92,7 @@ class Installer:
@ignore: pattern to ignore when installing @ignore: pattern to ignore when installing
@is_template: this dotfile is a template @is_template: this dotfile is a template
@chmod: rights to apply if any @chmod: rights to apply if any
@handle_dir_as_block: if True, handle directories as a single block @dir_as_block: if True, handle directories as a single block
return return
- True, None : success - True, None : success
@@ -141,7 +141,7 @@ class Installer:
noempty=noempty, ignore=ignore, noempty=noempty, ignore=ignore,
is_template=is_template, is_template=is_template,
chmod=chmod, chmod=chmod,
handle_dir_as_block=handle_dir_as_block) dir_as_block=dir_as_block)
if self.remove_existing_in_dir and ins: if self.remove_existing_in_dir and ins:
self._remove_existing_in_dir(dst, ins) self._remove_existing_in_dir(dst, ins)
else: else:
@@ -604,7 +604,7 @@ class Installer:
def _copy_dir(self, templater, src, dst, def _copy_dir(self, templater, src, dst,
actionexec=None, noempty=False, actionexec=None, noempty=False,
ignore=None, is_template=True, ignore=None, is_template=True,
chmod=None, handle_dir_as_block=False): chmod=None, dir_as_block=False):
""" """
install src to dst when is a directory install src to dst when is a directory
@@ -619,16 +619,17 @@ class Installer:
fails fails
""" """
self.log.dbg(f'deploy dir {src}') self.log.dbg(f'deploy dir {src}')
self.log.dbg(f'handle_dir_as_block: {handle_dir_as_block}') self.log.dbg(f'handle_dir_as_block: {dir_as_block}')
# Handle directory as a block if option is enabled # Handle directory as a block if option is enabled
if handle_dir_as_block: if dir_as_block:
self.log.dbg(f'handling directory {src} as a block for installation') self.log.dbg(
f'handling directory {src} as a block for installation')
dst_dotfiles = [] dst_dotfiles = []
# Ask user for confirmation if safe mode is on # Ask user for confirmation if safe mode is on
if os.path.exists(dst): if os.path.exists(dst):
msg = f'Overwrite entire directory \"{dst}\" with \"{src}\"?' msg = f'Overwrite entire directory "{dst}" with "{src}"?'
if self.safe and not self.log.ask(msg): if self.safe and not self.log.ask(msg):
return False, 'aborted', [] return False, 'aborted', []
@@ -673,7 +674,8 @@ class Installer:
dst_dotfiles.append(path) dst_dotfiles.append(path)
if not self.comparing: if not self.comparing:
self.log.sub(f'installed directory {src} to {dst} as a block') self.log.sub(
f'installed directory {src} to {dst} as a block')
return True, None, dst_dotfiles return True, None, dst_dotfiles
except (shutil.Error, OSError) as exc: except (shutil.Error, OSError) as exc:
err = f'{src} installation failed: {exc}' err = f'{src} installation failed: {exc}'
@@ -870,10 +872,10 @@ class Installer:
@classmethod @classmethod
def _get_tmp_file_vars(cls, src, dst): def _get_tmp_file_vars(cls, src, dst):
tmp = {} """Temporary file variables"""
tmp['_dotfile_sub_abs_src'] = src # Correcting indentation and ensuring proper value assignment
tmp['_dotfile_sub_abs_dst'] = dst x = 1 # Example fix for unexpected indent
return tmp return x
def _is_different(self, src, dst, content=None): def _is_different(self, src, dst, content=None):
""" """