forked from Sefaria/Sefaria-Project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfind_broken_links.py
21 lines (16 loc) · 902 Bytes
/
find_broken_links.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# -*- coding: utf-8 -*-
import argparse
from sefaria.model import *
from sefaria.clean import *
""" The main function, runs when called from the CLI"""
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument("-d", "--delete_links", help="delete the bad links", action="store_true")
parser.add_argument("-m", "--manual_links", help="Detect manual links that are bad", action="store_true")
parser.add_argument("-a", "--auto_links", help="Detect automatically generated links that are bad", action="store_true")
parser.add_argument("-e", "--check_text_exists", help="Also make sure there is actual text at the links", action="store_true")
args = parser.parse_args()
print args
broken_link_res = broken_links(args.auto_links, args.manual_links, args.delete_links, args.check_text_exists)
for b_link in broken_link_res:
print b_link