Skip to content

Commit

Permalink
Fix exit status which docopt errors.
Browse files Browse the repository at this point in the history
Fix archive_filter_options
Remove conflict between --all and --after (short for both was -A)
Output config to logfile.
Switch form of --exclude and --patterns command line options.
Fix match_archives
Improve tests
  • Loading branch information
Ken Kundert authored and Ken Kundert committed Dec 30, 2024
1 parent bfc219b commit 50be970
Show file tree
Hide file tree
Showing 7 changed files with 1,425 additions and 234 deletions.
25 changes: 15 additions & 10 deletions assimilate/assimilate.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,12 @@ def initialize(self, name, settings):
sub_configs = [name]
self.configs = sub_configs

comment(
config = name,
sub_configs = ', '.join(sub_configs),
template = ("config: {config} => ({subconfigs})", "config: {config}")
)

if self.composite_config_response == "first":
self.remaining_configs = sub_configs[0:1]
elif self.composite_config_response == "none":
Expand Down Expand Up @@ -508,26 +514,26 @@ def resolve_patterns(self, borg_opts, skip_checks=False):
patterns, roots, self.working_dir, "patterns",
skip_checks=skip_checks
):
borg_opts.extend(["--pattern", pattern])
borg_opts.append(f"--pattern={pattern}")

excludes = self.values("excludes")
if excludes:
for exclude in check_excludes(excludes, roots, "excludes"):
borg_opts.extend(["--exclude", exclude])
borg_opts.append(f"--exclude={exclude}")

patterns_froms = self.as_paths("patterns_from", must_exist=True)
if patterns_froms:
check_patterns_files(
patterns_froms, roots, self.working_dir, skip_checks=skip_checks
)
for patterns_from in patterns_froms:
borg_opts.extend(["--patterns-from", patterns_from])
borg_opts.append(f"--patterns-from={patterns_from}")

exclude_froms = self.as_paths("exclude_from", must_exist=True)
if exclude_froms:
check_excludes_files(exclude_froms, roots)
for exclude_from in exclude_froms:
borg_opts.extend(["--exclude-from", exclude_from])
borg_opts.append(f"--exclude-from={exclude_from}")

if not skip_checks:
check_roots(roots, self.working_dir)
Expand Down Expand Up @@ -613,8 +619,7 @@ def borg_options(self, cmd, borg_opts, assimilate_opts, strip_archive_matcher):
val = self.value(name)
if val:
if name == "match_archives":
if '--match-archives':
borg_opts.extend([f"{opt}={v.strip()!s}" for v in self.value(name)])
borg_opts.extend([f"{opt}={v.strip()!s}" for v in val])
elif "arg" in attrs and attrs["arg"]:
borg_opts.append(f"{opt}={val!s}")
else:
Expand Down Expand Up @@ -915,10 +920,10 @@ def __enter__(self):
if "archive" not in self.settings:
self.settings["archive"] = "{host_name}-{user_name}-{config_name}-{{now}}"
archive = self.settings["archive"]
if "match_archives" not in self.settings:
match_archives = archive.replace('{{now}}', '*')
match_archives = match_archives.replace('{{utcnow}}', '*')
self.settings["match_archives"] = ['sh:' + match_archives]
match_archives = archive.replace('{{now}}', '*')
match_archives = match_archives.replace('{{utcnow}}', '*')
self.settings["match_archives"] = ['sh:' + match_archives]
self.match_local_archives = 'sh:' + match_archives
match_archives = self.settings["match_archives"]
for ma in match_archives:
prefix, _, identifier = ma.partition(':')
Expand Down
Loading

0 comments on commit 50be970

Please sign in to comment.