MCPcopy
hub / github.com/ArchiveBox/ArchiveBox / printable_folder_status

Function printable_folder_status

archivebox/logging_util.py:598–634  ·  view source on GitHub ↗
(name: str, folder: Dict)

Source from the content-addressed store, hash-verified

596
597@enforce_types
598def printable_folder_status(name: str, folder: Dict) -> str:
599 if folder['enabled']:
600 if folder['is_valid']:
601 color, symbol, note, num_files = 'green', '√', 'valid', ''
602 else:
603 color, symbol, note, num_files = 'red', 'X', 'invalid', '?'
604 else:
605 color, symbol, note, num_files = 'lightyellow', '-', 'disabled', '-'
606
607
608 if folder['path']:
609 if Path(folder['path']).exists():
610 num_files = (
611 f'{len(os.listdir(folder["path"]))} files'
612 if Path(folder['path']).is_dir() else
613 printable_filesize(Path(folder['path']).stat().st_size)
614 )
615 else:
616 num_files = 'missing'
617
618 if folder.get('is_mount'):
619 # add symbol @ next to filecount if path is a remote filesystem mount
620 num_files = f'{num_files} @' if num_files else '@'
621
622 path = pretty_path(folder['path'])
623
624 return ' '.join((
625 ANSI[color],
626 symbol,
627 ANSI['reset'],
628 name.ljust(21),
629 num_files.ljust(14),
630 ANSI[color],
631 note.ljust(8),
632 ANSI['reset'],
633 path.ljust(76),
634 ))
635
636
637@enforce_types

Callers 1

versionFunction · 0.85

Calls 3

printable_filesizeFunction · 0.85
pretty_pathFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected