-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcli.py
More file actions
31 lines (24 loc) · 790 Bytes
/
cli.py
File metadata and controls
31 lines (24 loc) · 790 Bytes
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
import argparse
import os
import sys
import my_index
def test(ix):
from whoosh.query import Every
results = ix.searcher().search(Every('session'), limit=None)
for result in results:
pass
def main():
parser = argparse.ArgumentParser()
parser.add_argument("-i", "--interactive", help="load search index interactively", action='store_true')
parser.add_argument("-r", "--rebuild", help="rebuild index", nargs='?', const="index")
parser.add_argument("-t", "--test", help="test", action='store_true')
args = parser.parse_args()
if args.rebuild:
my_index.new_index(args.rebuild)
else:
os.chdir(sys.path[0])
ix = my_index.get_idx('index')
if args.test:
test(ix)
if __name__ == '__main__':
main()