-
Notifications
You must be signed in to change notification settings - Fork 0
/
parsing_definitions.py
65 lines (56 loc) · 1.97 KB
/
parsing_definitions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import argparse
def create_parser():
## Setup command line arguments
# Custom Types
help_message = """Description: This commandline utility searches the entire Goldsmiths website (gold.ac.uk) for occurences of the specificed search term(s)."""
parser = argparse.ArgumentParser(description=help_message)
# Arguments
parser.add_argument(
dest="searchterms",
nargs="+",
help='Specify at least one word or phrase you would like to search for, wrapped in quotes (e.g. "apply through clearing" "clearing applications")',
)
# Flags
parser.add_argument(
"-s",
"--sitemap",
dest="custom_sitemap",
default="sitemap.csv",
help="Specify the path to a sitemap file. If left blank defaults to sitemap.csv",
)
parser.add_argument(
"-u",
"--url-filters",
dest="url_filters",
nargs="+",
help="Specify plaintext patterns to filter search urls by (e.g. /ug/, /pg/, /careers/)",
)
parser.add_argument(
"-d",
"--debug",
dest="debug",
action="store_true",
help="Used for debugging. Will print out all arguments you set, without running a search (kind of like a dry run).",
)
parser.add_argument(
"-v",
"--verbose",
dest="verbose",
action="store_true",
help=f"Used for debugging. Prints out verbose output. Useful for checking what's happening behind the scenes.",
)
parser.add_argument(
"-po",
"--printoutput",
dest="print_output",
action="store_true",
help=f"Print real-time output to terminal as well as writing to csv. This will replace all the .'s printed otherwise.",
)
parser.add_argument(
"-n",
"--outputname",
dest="output_name",
nargs="+",
help=f"Give a custom filename for the results csv (wrapped in quotes.) The .csv file extension is added automatically.",
)
return parser