From a94096910b3b95629e96e809ec21a705505fe841 Mon Sep 17 00:00:00 2001 From: Jermiah Joseph Date: Thu, 21 Nov 2024 16:47:19 -0500 Subject: [PATCH] fix: common prefix for tree --- src/imgtools/dicom/sort/dicomsorter.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/imgtools/dicom/sort/dicomsorter.py b/src/imgtools/dicom/sort/dicomsorter.py index 8b5f33f1..bdd7e82d 100644 --- a/src/imgtools/dicom/sort/dicomsorter.py +++ b/src/imgtools/dicom/sort/dicomsorter.py @@ -260,13 +260,16 @@ def _dry_run(self, file_map: Dict[Path, Path]) -> None: ) new_paths = sorted(list(file_map.values())) - common_prefix: Path = self._common_prefix(new_paths) + ppa = Path(self.pattern_preview).absolute() + common_prefix: Path = self._common_prefix([ppa, *new_paths]) common_prefix_styled = f'[bold yellow]{common_prefix}[/bold yellow]' self._console.print(f'\nCommon Prefix: :file_folder:{common_prefix_styled}\n\n') tree = self._setup_tree(Path(common_prefix_styled)) + + root = ppa.relative_to(common_prefix).as_posix() self._generate_tree_structure( - Path(self.pattern_preview).absolute().relative_to(common_prefix).as_posix(), + root, tree, ) self._build_tree(new_paths, tree, common_prefix)