MCPcopy
hub / github.com/ArchiveBox/ArchiveBox / remove

Function remove

archivebox/main.py:701–777  ·  view source on GitHub ↗

Remove the specified URLs from the archive

(filter_str: Optional[str]=None,
           filter_patterns: Optional[List[str]]=None,
           filter_type: str='exact',
           snapshots: Optional[QuerySet]=None,
           after: Optional[float]=None,
           before: Optional[float]=None,
           yes: bool=False,
           delete: bool=False,
           out_dir: Path=OUTPUT_DIR)

Source from the content-addressed store, hash-verified

699
700@enforce_types
701def remove(filter_str: Optional[str]=None,
702 filter_patterns: Optional[List[str]]=None,
703 filter_type: str='exact',
704 snapshots: Optional[QuerySet]=None,
705 after: Optional[float]=None,
706 before: Optional[float]=None,
707 yes: bool=False,
708 delete: bool=False,
709 out_dir: Path=OUTPUT_DIR) -> List[Link]:
710 """Remove the specified URLs from the archive"""
711
712 check_data_folder(out_dir=out_dir)
713
714 if snapshots is None:
715 if filter_str and filter_patterns:
716 stderr(
717 '[X] You should pass either a pattern as an argument, '
718 'or pass a list of patterns via stdin, but not both.\n',
719 color='red',
720 )
721 raise SystemExit(2)
722 elif not (filter_str or filter_patterns):
723 stderr(
724 '[X] You should pass either a pattern as an argument, '
725 'or pass a list of patterns via stdin.',
726 color='red',
727 )
728 stderr()
729 hint(('To remove all urls you can run:',
730 'archivebox remove --filter-type=regex ".*"'))
731 stderr()
732 raise SystemExit(2)
733 elif filter_str:
734 filter_patterns = [ptn.strip() for ptn in filter_str.split('\n')]
735
736 list_kwargs = {
737 "filter_patterns": filter_patterns,
738 "filter_type": filter_type,
739 "after": after,
740 "before": before,
741 }
742 if snapshots:
743 list_kwargs["snapshots"] = snapshots
744
745 log_list_started(filter_patterns, filter_type)
746 timer = TimedProgress(360, prefix=' ')
747 try:
748 snapshots = list_links(**list_kwargs)
749 finally:
750 timer.end()
751
752
753 if not snapshots.exists():
754 log_removal_finished(0, 0)
755 raise SystemExit(1)
756
757
758 log_links = [link.as_link() for link in snapshots]

Callers 2

delete_snapshotsMethod · 0.90
mainFunction · 0.85

Calls 14

endMethod · 0.95
check_data_folderFunction · 0.85
stderrFunction · 0.85
hintFunction · 0.85
log_list_startedFunction · 0.85
TimedProgressClass · 0.85
list_linksFunction · 0.85
log_removal_finishedFunction · 0.85
log_list_finishedFunction · 0.85
log_removal_startedFunction · 0.85
flush_search_indexFunction · 0.85

Tested by

no test coverage detected