(node, parent_path='')
| 2521 | print('\n'.join(lines) + '\n') |
| 2522 | |
| 2523 | def tree_node(node, parent_path=''): |
| 2524 | node_uid = node.record_uid if isinstance(node, Record) else (node.uid if hasattr(node, 'uid') else '') |
| 2525 | node_name = node.title if isinstance(node, Record) else (node.name if hasattr(node, 'name') else 'Unknown') |
| 2526 | |
| 2527 | is_nested_share = False |
| 2528 | if isinstance(node, Record): |
| 2529 | is_nested_share = hasattr(params, 'nested_share_records') and node.record_uid in params.nested_share_records |
| 2530 | elif hasattr(node, 'type') and node.type == 'nested_share_folder': |
| 2531 | is_nested_share = True |
| 2532 | elif isinstance(node, BaseFolderNode) and not isinstance(node, Record): |
| 2533 | is_nested_share = hasattr(params, 'nested_share_folders') and node_uid in params.nested_share_folders |
| 2534 | if is_nested_share and node_uid in params.nested_share_folders: |
| 2535 | nsf_folder_name = params.nested_share_folders[node_uid].get('name', node_name) |
| 2536 | if nsf_folder_name: |
| 2537 | node_name = nsf_folder_name |
| 2538 | |
| 2539 | base_name = node_name |
| 2540 | if is_nested_share and not isinstance(node, Record) and node_uid in getattr(params, 'nested_share_folders', {}): |
| 2541 | base_name = params.nested_share_folders[node_uid].get('name') or base_name |
| 2542 | |
| 2543 | is_vault_root = isinstance(node, BaseFolderNode) and (getattr(node, 'type', None) == '/' or not node_uid) |
| 2544 | if is_vault_root and not isinstance(node, Record): |
| 2545 | node_path = '/' |
| 2546 | else: |
| 2547 | node_path = _join_tree_path(parent_path, base_name) |
| 2548 | |
| 2549 | display_name = f'{node_name} ({node_uid})' if verbose else node_name |
| 2550 | share_text = '' |
| 2551 | share_data = None |
| 2552 | kind = 'folder' |
| 2553 | record_type = None |
| 2554 | |
| 2555 | if isinstance(node, Record): |
| 2556 | kind = 'nested_record' if is_nested_share else 'record' |
| 2557 | record_type = getattr(node, 'record_type', None) or '' |
| 2558 | type_label = f' [{record_type}]' if record_type else '' |
| 2559 | nsf_label = ' [Nested Record]' if is_nested_share else ' [Record]' |
| 2560 | if is_nested_share and nsf_shares: |
| 2561 | share_data, share_text = _nsf_record_share_data( |
| 2562 | params, node_uid, include_uids=verbose) |
| 2563 | elif (not is_nested_share) and shares: |
| 2564 | share_data, share_text = _classic_record_share_data( |
| 2565 | params, node_uid, include_uids=verbose) |
| 2566 | display_name = f'{Style.DIM}{display_name}{type_label}{nsf_label}{share_text}{Style.NORMAL}' |
| 2567 | elif isinstance(node, SharedFolderNode): |
| 2568 | kind = 'shared_folder' |
| 2569 | if shares: |
| 2570 | share_data, share_text = _classic_folder_share_data( |
| 2571 | params, params.shared_folder_cache.get(node.uid), include_uids=verbose) |
| 2572 | display_name = f'{display_name}{Style.BRIGHT} [SHARED]{Style.NORMAL}{share_text}' |
| 2573 | elif is_nested_share: |
| 2574 | kind = 'nested_share_folder' |
| 2575 | if nsf_shares and node_uid: |
| 2576 | share_data, share_text = _nsf_folder_share_data( |
| 2577 | params, node_uid, include_uids=verbose) |
| 2578 | display_name = f'{display_name}{Style.BRIGHT} [Nested Share Folder]{Style.NORMAL}{share_text}' |
| 2579 | |
| 2580 | dir_nodes = [] |
no test coverage detected