-
Notifications
You must be signed in to change notification settings - Fork 0
/
seek_library.py
101 lines (88 loc) · 3.24 KB
/
seek_library.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import requests
import json
import string
import getpass
import sys
import io
import ipywidgets as widgets
import functools as ft
# Importing the libraries we need to format the data in a more readable way.
import pandas as pd
from query import Query
from search import Search
from write import Write
from json_methods import JSON_methods
from pandas.io.json import json_normalize
from multiprocessing import Pool
from IPython.display import display
from IPython.display import HTML
from IPython.display import clear_output
# from IPython.core.interactiveshell import InteractiveShell
# InteractiveShell.ast_node_interactivity = "all"
display_In_Widgets = 0;
'''
To run
x= s.SEEK()
'''
class SEEK():
'''
Container of all classes
All functions are called from this class
FUNCTIONS :
query : select ID and type for searching
post : post a json
search : search a file based on query
query : set login details
change_url : FOR DEMO PURPOSE ONLY
Change url to sandbox website
'''
def __init__(self):
self.json_handler = JSON_methods()
self.SEEK_query = None
self.SEEK_search = None
self.SEEK_write = None
def query(self):
self.SEEK_query = Query(self.json_handler)
self.SEEK_query.query()
def post(self):
if self.SEEK_write == None :
self.SEEK_write = Write(self.json_handler)
self.SEEK_write.post_choice()
def search(self):
self.SEEK_search = Search(self.json_handler)
valid = True
list_of_names = self.SEEK_query.get_list_of_user_names()
list_of_ids = self.SEEK_query.get_list_of_user_ids()
topic = self.SEEK_query.get_topic()
if topic == 'Document query' or topic == 'Person query':
settings_dict = self.SEEK_query.get_setting_options_dict()
settings_dict = dict(settings_dict)
id = self.SEEK_query.get_id_to_search()
if id == '':
print('ID is needed')
valid = False
type = self.SEEK_query.get_type_to_search()
if valid == True :
self.SEEK_search.search_parameters(topic,id,type,settings_dict,list_of_names,list_of_ids)
self.SEEK_search.search()
else :
print('Select Document/Person query tab to search')
def change_url(self):
print('1: https://www.fairdomhub.org')
print('2: https://sandbox3.fairdomhub.org')
choice = input("Please choose url 1 or 2:\n")
print('You entered {0}'.format(choice))
self.json_handler.change_url(choice)
if self.SEEK_query != None:
self.SEEK_query.set_json_handler(self.json_handler)
if self.SEEK_search != None:
self.SEEK_search.set_json_handler(self.json_handler)
def auth(self):
self.json_handler.auth_request()
# self.SEEK_query.set_json_handler(self.json_handler)
if self.SEEK_query != None:
self.SEEK_query.set_json_handler(self.json_handler)
if self.SEEK_search != None:
self.SEEK_search.set_json_handler(self.json_handler)
if self.SEEK_write != None:
self.SEEK_write.set_json_handler(self.json_handler)