MCPcopy Index your code
hub / github.com/zer0yu/CyberSecurityRSS / main

Function main

scripts/opml_sync.py:682–731  ·  view source on GitHub ↗
(argv: Optional[List[str]] = None)

Source from the content-addressed store, hash-verified

680
681
682def main(argv: Optional[List[str]] = None) -> int:
683 parser = build_parser()
684 args = parser.parse_args(argv)
685 try:
686 stats, changed = run_sync(
687 tiny_path=Path(args.tiny),
688 full_path=Path(args.full),
689 mode=args.mode,
690 fallback_category=args.fallback_category,
691 timeout=args.timeout,
692 retries=max(1, args.retries),
693 workers=max(1, args.workers),
694 state_file=Path(args.state_file),
695 delete_threshold=max(1, args.delete_threshold),
696 max_probe_bytes=max(1024, args.max_probe_bytes),
697 )
698 except Exception as exc:
699 print(f"Error: {exc}", file=sys.stderr)
700 return 2
701
702 print(
703 "Summary: checked={checked} alive={alive} dead={dead} hard_fail={hard} transient_fail={transient} "
704 "removed_dead={removed_dead} retained_failed={retained_failed} removed_dups={removed_dups} merged_added={merged} "
705 "tiny_before={tiny_before} tiny_after={tiny_after} "
706 "full_before={full_before} full_after={full_after}".format(
707 checked=stats.checked_urls,
708 alive=stats.alive_urls,
709 dead=stats.dead_urls,
710 hard=stats.hard_fail_urls,
711 transient=stats.transient_fail_urls,
712 removed_dead=stats.dead_removed_total,
713 retained_failed=stats.retained_failed_total,
714 removed_dups=stats.duplicates_removed_total,
715 merged=stats.merged_added_full,
716 tiny_before=stats.tiny_links_before,
717 tiny_after=stats.tiny_links_after,
718 full_before=stats.full_links_before,
719 full_after=stats.full_links_after,
720 )
721 )
722 print(json.dumps(stats.to_dict(), ensure_ascii=False, sort_keys=True))
723
724 if args.mode == "check" and changed:
725 print(
726 "Detected OPML drift: run in apply mode to update files "
727 "(or merge to master and let workflow auto-fix).",
728 file=sys.stderr,
729 )
730 return 1
731 return 0
732
733
734if __name__ == "__main__":

Callers 1

opml_sync.pyFile · 0.70

Calls 3

build_parserFunction · 0.85
run_syncFunction · 0.85
to_dictMethod · 0.80

Tested by

no test coverage detected