Browse Source

Minor cleanup

pull/11/head
Ryan Reed 1 year ago
parent
commit
6a7e61889f
2 changed files with 5 additions and 13 deletions
  1. +5
    -12
      src/transpose/console.py
  2. +0
    -1
      tests/test_console.py

+ 5
- 12
src/transpose/console.py View File

@ -21,7 +21,7 @@ def run(args, config_path) -> None:
if args.action == "apply": if args.action == "apply":
t.apply(args.name, force=args.force) t.apply(args.name, force=args.force)
if args.action == "apply-all":
elif args.action == "apply-all":
run_apply_all(t, force=args.force) run_apply_all(t, force=args.force)
elif args.action == "restore": elif args.action == "restore":
t.restore(args.name, force=args.force) t.restore(args.name, force=args.force)
@ -51,7 +51,7 @@ def run_apply_all(t: Transpose, force: bool = False) -> None:
""" """
Loop over the entries and recreate the symlinks to the store location Loop over the entries and recreate the symlinks to the store location
Useful after restoring the machine
Useful after restoring a machine
Args: Args:
t: An instance of Transpose t: An instance of Transpose
@ -60,19 +60,12 @@ def run_apply_all(t: Transpose, force: bool = False) -> None:
Returns: Returns:
None None
""" """
results = {}
for entry_name in t.config.entries:
for entry_name in sorted(t.config.entries):
try: try:
t.apply(entry_name, force) t.apply(entry_name, force)
results[entry_name] = {"status": "success", "error": ""}
print(f"\t{entry_name:<30}: success")
except TransposeError as e: except TransposeError as e:
results[entry_name] = {"status": "failure", "error": str(e)}
for name in sorted(results):
if results[name]["status"] != "success":
print(f"\t{name:<30}: {results[name]['error']}")
else:
print(f"\t{name:<30}: success")
print(f"\t{entry_name:<30}: {e}")
def parse_arguments(args=None): def parse_arguments(args=None):


+ 0
- 1
tests/test_console.py View File

@ -161,7 +161,6 @@ def test_run_apply_all(capsys):
assert f"\t{ENTRY_NAME:<30}: success" in captured.out assert f"\t{ENTRY_NAME:<30}: success" in captured.out
assert f"\t{SECOND_ENTRY_NAME:<30}: success" in captured.out assert f"\t{SECOND_ENTRY_NAME:<30}: success" in captured.out
assert SECOND_TARGET_PATH.is_symlink() assert SECOND_TARGET_PATH.is_symlink()
assert SECOND_TARGET_PATH.with_suffix(".backup").is_dir() assert SECOND_TARGET_PATH.with_suffix(".backup").is_dir()


Loading…
Cancel
Save