-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.py
More file actions
56 lines (46 loc) · 1.38 KB
/
main.py
File metadata and controls
56 lines (46 loc) · 1.38 KB
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
import sys
from pymongo import MongoClient
from pymongo.collection import Collection
from ui import *
from tasks import task_dict
def main(port):
# make a connection
try:
client = MongoClient(f"mongodb://localhost:{port}")
except:
print(f"Invalid port: {port}")
exit()
# load the collection
db = client["291db"]
try:
collection_list = db.list_collection_names()
except:
print(f"Invalid port: {port}")
exit()
if "dblp" not in collection_list:
print("Data not loaded yet")
exit()
if "dblp-article-count" in collection_list:
db["dblp-article-count"].drop()
if "dblp-zero-citation" in collection_list:
db["dblp-zero-citation"].drop()
dblp = db["dblp"]
# display UI & ask for selection
while True:
print(MAIN_UI)
opt = input("Select one option: ")
while opt not in task_dict:
print("Please make a proper selection")
opt = input("Select one option: ")
if opt == "3":
dblp_venue = db["dblp-citation-count"]
task_dict[opt](dblp_venue)
continue
# process corresponding action
if task_dict[opt] is None:
client.close()
exit()
task_dict[opt](dblp)
if __name__ == "__main__":
port = input("port: ")
main(port)