@@ -18,7 +18,7 @@ from typing import List, Optional |
| 18 | | 18 | |
| 19 | from .args import parse_arguments | 19 | from .args import parse_arguments |
| 20 | from .traversal import SecureTraverser, FileEntry | 20 | from .traversal import SecureTraverser, FileEntry |
| 21 | -from .formatting import TreeFormatter | 21 | +from .tree_renderer import TreeRenderer, build_tree_structure |
| 22 | from .selinux import is_selinux_enabled, SELinuxQueryError | 22 | from .selinux import is_selinux_enabled, SELinuxQueryError |
| 23 | from .constants import CONFIG | 23 | from .constants import CONFIG |
| 24 | | 24 | |
@@ -46,7 +46,7 @@ def setup_logging(verbose: bool = False) -> None: |
| 46 | | 46 | |
| 47 | | 47 | |
| 48 | def process_directory(directory: Path, traverser: SecureTraverser, | 48 | def process_directory(directory: Path, traverser: SecureTraverser, |
| 49 | - formatter: TreeFormatter) -> bool: | 49 | + renderer: TreeRenderer) -> bool: |
| 50 | """ | 50 | """ |
| 51 | Process a single directory and display its tree. | 51 | Process a single directory and display its tree. |
| 52 | | 52 | |
@@ -66,9 +66,12 @@ def process_directory(directory: Path, traverser: SecureTraverser, |
| 66 | for entry in traverser.traverse(directory): | 66 | for entry in traverser.traverse(directory): |
| 67 | entries.append(entry) | 67 | entries.append(entry) |
| 68 | | 68 | |
| 69 | - # Format and display the tree | 69 | + # Build proper tree structure |
| | 70 | + root_node = build_tree_structure(entries, directory) |
| | 71 | + |
| | 72 | + # Render the tree |
| 70 | show_report = True # Could be made configurable | 73 | show_report = True # Could be made configurable |
| 71 | - formatter.format_tree(directory, entries, show_report) | 74 | + renderer.render_tree(directory, root_node, show_report) |
| 72 | | 75 | |
| 73 | return True | 76 | return True |
| 74 | | 77 | |
@@ -137,13 +140,13 @@ def main() -> int: |
| 137 | # Setup logging if needed (could add --verbose flag) | 140 | # Setup logging if needed (could add --verbose flag) |
| 138 | setup_logging(verbose=False) | 141 | setup_logging(verbose=False) |
| 139 | | 142 | |
| 140 | - # Create traverser and formatter | 143 | + # Create traverser and renderer |
| 141 | traverser = SecureTraverser(options) | 144 | traverser = SecureTraverser(options) |
| 142 | | 145 | |
| 143 | # Determine if SELinux context should be shown | 146 | # Determine if SELinux context should be shown |
| 144 | show_selinux = options.selinux_filter is not None | 147 | show_selinux = options.selinux_filter is not None |
| 145 | | 148 | |
| 146 | - formatter = TreeFormatter( | 149 | + renderer = TreeRenderer( |
| 147 | show_full_path=options.show_full_path, | 150 | show_full_path=options.show_full_path, |
| 148 | show_selinux=show_selinux, | 151 | show_selinux=show_selinux, |
| 149 | use_ascii=False # Could be made configurable | 152 | use_ascii=False # Could be made configurable |
@@ -159,7 +162,7 @@ def main() -> int: |
| 159 | print() # Empty line between directories | 162 | print() # Empty line between directories |
| 160 | | 163 | |
| 161 | # Process directory | 164 | # Process directory |
| 162 | - if process_directory(directory, traverser, formatter): | 165 | + if process_directory(directory, traverser, renderer): |
| 163 | success_count += 1 | 166 | success_count += 1 |
| 164 | else: | 167 | else: |
| 165 | logger.warning(f"Failed to process directory: {directory}") | 168 | logger.warning(f"Failed to process directory: {directory}") |