-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmanage.py
59 lines (48 loc) · 1.26 KB
/
manage.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
from flask_script import Manager
from python_search.frontend.app import app
from python_search import scraper, indexer
manager = Manager(app)
@manager.option(
"--parallelism",
help="The number of parallel scraping processes to use",
type=int,
default=4,
)
@manager.option(
"--start_at", help="The mailing list to start at (alphabetically)"
)
@manager.option("--update", type=bool)
def scrape(parallelism, start_at, update):
scraper.scrape_cmd(parallelism, start_at, update)
@manager.option(
"--db",
help="The file of the database",
required=True
)
@manager.option(
"--index_dir", help="The directory of the index",
required=True
)
def index(db, index_dir):
indexer.index_cmd(db, index_dir)
@manager.option(
"--index_dir", help="The directory of the index",
required=True
)
@manager.option(
"--query", help="Query to search index for",
required=True
)
def search(index_dir, query):
searcher = indexer.IndexSearcher(index_dir)
results = searcher.search(query)
print(list(results))
@manager.option(
"--index_dir", help="The directory of the index",
required=True
)
def run(index_dir):
app.config["index_dir"] = index_dir
app.run(debug=True)
if __name__ == "__main__":
manager.run()