(node, parent_path='')
| 2622 | print('\n'.join(lines) + '\n') |
| 2623 | |
| 2624 | def tree_node(node, parent_path=''): |
| 2625 | node_uid = node.record_uid if isinstance(node, Record) else (node.uid if hasattr(node, 'uid') else '') |
| 2626 | node_name = node.title if isinstance(node, Record) else (node.name if hasattr(node, 'name') else 'Unknown') |
| 2627 | |
| 2628 | is_nested_share = False |
| 2629 | if isinstance(node, Record): |
| 2630 | is_nested_share = hasattr(params, 'nested_share_records') and node.record_uid in params.nested_share_records |
| 2631 | elif hasattr(node, 'type') and node.type == 'nested_share_folder': |
| 2632 | is_nested_share = True |
| 2633 | elif isinstance(node, BaseFolderNode) and not isinstance(node, Record): |
| 2634 | is_nested_share = hasattr(params, 'nested_share_folders') and node_uid in params.nested_share_folders |
| 2635 | if is_nested_share and node_uid in params.nested_share_folders: |
| 2636 | nsf_folder_name = params.nested_share_folders[node_uid].get('name', node_name) |
| 2637 | if nsf_folder_name: |
| 2638 | node_name = nsf_folder_name |
| 2639 | |
| 2640 | base_name = node_name |
| 2641 | if is_nested_share and not isinstance(node, Record) and node_uid in getattr(params, 'nested_share_folders', {}): |
| 2642 | base_name = params.nested_share_folders[node_uid].get('name') or base_name |
| 2643 | |
| 2644 | is_vault_root = isinstance(node, BaseFolderNode) and (getattr(node, 'type', None) == '/' or not node_uid) |
| 2645 | if is_vault_root and not isinstance(node, Record): |
| 2646 | node_path = '/' |
| 2647 | else: |
| 2648 | node_path = _join_tree_path(parent_path, base_name) |
| 2649 | |
| 2650 | display_name = f'{node_name} ({node_uid})' if verbose else node_name |
| 2651 | share_text = '' |
| 2652 | share_data = None |
| 2653 | kind = 'folder' |
| 2654 | record_type = None |
| 2655 | |
| 2656 | if isinstance(node, Record): |
| 2657 | kind = 'nested_record' if is_nested_share else 'record' |
| 2658 | record_type = getattr(node, 'record_type', None) or '' |
| 2659 | type_label = f' [{record_type}]' if record_type else '' |
| 2660 | nsf_label = ' [Nested Record]' if is_nested_share else ' [Record]' |
| 2661 | if is_nested_share and nsf_shares: |
| 2662 | share_data, share_text = _nsf_record_share_data( |
| 2663 | params, node_uid, include_uids=verbose) |
| 2664 | elif (not is_nested_share) and shares: |
| 2665 | share_data, share_text = _classic_record_share_data( |
| 2666 | params, node_uid, include_uids=verbose) |
| 2667 | display_name = f'{Style.DIM}{display_name}{type_label}{nsf_label}{share_text}{Style.NORMAL}' |
| 2668 | elif isinstance(node, SharedFolderNode): |
| 2669 | kind = 'shared_folder' |
| 2670 | if shares: |
| 2671 | share_data, share_text = _classic_folder_share_data( |
| 2672 | params, params.shared_folder_cache.get(node.uid), include_uids=verbose) |
| 2673 | display_name = f'{display_name}{Style.BRIGHT} [SHARED]{Style.NORMAL}{share_text}' |
| 2674 | elif is_nested_share: |
| 2675 | kind = 'nested_share_folder' |
| 2676 | if nsf_shares and node_uid: |
| 2677 | share_data, share_text = _nsf_folder_share_data( |
| 2678 | params, node_uid, include_uids=verbose) |
| 2679 | display_name = f'{display_name}{Style.BRIGHT} [Nested Share Folder]{Style.NORMAL}{share_text}' |
| 2680 | |
| 2681 | dir_nodes = [] |
no test coverage detected