Skip to content

Commit 080319c

Browse files
committed
Prepare argparse parameters
1 parent afc8459 commit 080319c

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

check_urls.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env python
2+
import argparse
23
import multiprocessing as mp
34
import os
45
import json
@@ -97,7 +98,28 @@ def bad_url(url_status):
9798
return False
9899

99100

101+
102+
def parse_args(argv):
103+
parser = argparse.ArgumentParser(
104+
description='Check correctness of url links.',
105+
add_help=True)
106+
parser.add_argument(
107+
'url-timeout',
108+
default=10.0,
109+
help='Timeout in seconds to wait for link')
110+
parser.add_argument(
111+
'url-retries',
112+
default=10,
113+
help='Number of link retries')
114+
parser.add_argument(
115+
'num-threads',
116+
default=mp.cpu_count()*4,
117+
help='Number of threads to run with')
118+
return parser.parse_args(argv)
119+
120+
100121
def main():
122+
args = parse_args(sys.argv[1:])
101123
print('Extract urls...')
102124
all_urls = extract_urls(os.getcwd() + os.path.sep + 'content')
103125
print('\nCheck urls...')

0 commit comments

Comments
 (0)