This repository has been archived by the owner on Sep 18, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmain.py
397 lines (375 loc) · 27.1 KB
/
main.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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
import click
import getpass
import re
import sys
import time
import wikipedia
class wikiclss():
def __init__(self, srchqery):
self.srchqery = srchqery
def obtntime(self):
timestmp = time.localtime()
timehour = str(timestmp.tm_hour)
timemint = str(timestmp.tm_min)
timesecs = str(timestmp.tm_sec)
if int(timehour) < 10: timehour = "0" + timehour
if int(timemint) < 10: timemint = "0" + timemint
if int(timesecs) < 10: timesecs = "0" + timesecs
return timehour + ":" + timemint + ":" + timesecs
def prsehead(self, purltext):
while re.search("===== (.*) =====", purltext):
purltext = purltext.replace("\n===== " + re.search("===== (.*) =====", purltext).group(1) + " =====", click.style(re.search("===== (.*) =====", purltext).group(1) + " > ", fg="green", bold=True))
while re.search("==== (.*) ====", purltext):
purltext = purltext.replace("\n==== " + re.search("==== (.*) ====", purltext).group(1) + " ====", click.style(re.search("==== (.*) ====", purltext).group(1) + " > ", fg="blue", bold=True))
while re.search("=== (.*) ===", purltext):
purltext = purltext.replace("\n=== " + re.search("=== (.*) ===", purltext).group(1) + " ===", click.style(re.search("=== (.*) ===", purltext).group(1) + " > ", fg="red", bold=True))
while re.search("== (.*) ==", purltext):
purltext = purltext.replace("\n== " + re.search("== (.*) ==", purltext).group(1) + " ==", click.style(re.search("== (.*) ==", purltext).group(1) + " > ", fg="magenta", bold=True))
return purltext
def getpgurl(self):
if self.srchqery is None:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "You do not seem to have provided a search query")
sys.exit()
else:
try:
strttime = time.monotonic()
purltext = wikipedia.page(self.srchqery).url
stoptime = time.monotonic()
duration = stoptime - strttime
click.echo(click.style("RESULT > ", fg="green", bold=True) + click.style("URL > ", fg="blue", bold=True) + purltext)
click.echo(click.style("RAISED > ", fg="green", bold=True) + "1 result in " + str(duration)[0:3] + " seconds [" + self.obtntime() + "]")
except wikipedia.exceptions.PageError:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "Couldn't find the Wikipedia page for the query.")
except wikipedia.exceptions.DisambiguationError:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "The query resolves to a Disambiguation page.")
except wikipedia.exceptions.RedirectError:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "Page title unexpectedly resolved to a redirect.")
except wikipedia.exceptions.HTTPTimeoutError:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "Timeout occured while processing the query.")
except wikipedia.exceptions.WikipediaException:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "Base Wikipedia exception class.")
except Exception:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "Exception occurred due to which results could not be displayed")
def gettitle(self):
if self.srchqery is None:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "You do not seem to have provided a search query")
sys.exit()
else:
try:
strttime = time.monotonic()
purltext = wikipedia.page(self.srchqery).title
stoptime = time.monotonic()
duration = stoptime - strttime
click.echo(click.style("RESULT > ", fg="green", bold=True) + click.style("TITLE > ", fg="blue", bold=True) + purltext)
click.echo(click.style("RAISED > ", fg="green", bold=True) + "1 result in " + str(duration)[0:3] + " seconds [" + self.obtntime() + "]")
except wikipedia.exceptions.PageError:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "Couldn't find the Wikipedia page for the query.")
except wikipedia.exceptions.DisambiguationError:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "The query resolves to a Disambiguation page.")
except wikipedia.exceptions.RedirectError:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "Page title unexpectedly resolved to a redirect.")
except wikipedia.exceptions.HTTPTimeoutError:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "Timeout occured while processing the query.")
except wikipedia.exceptions.WikipediaException:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "Base Wikipedia exception class.")
except Exception:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "Exception occurred due to which results could not be displayed")
def savehtml(self):
if self.srchqery is None:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "You do not seem to have provided a search query")
sys.exit()
def getlinks(self):
if self.srchqery is None:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "You do not seem to have provided a search query")
sys.exit()
else:
try:
strttime = time.monotonic()
purltext = wikipedia.page(self.srchqery).links
stoptime = time.monotonic()
duration = stoptime - strttime
click.echo(click.style("RESULT > ", fg="green", bold=True) + click.style("LINKS > ", fg="blue", bold=True))
max_width = len(str(len(purltext)))+1
for indx in range(len(purltext)):
click.echo(click.style(f"#{indx+1}".rjust(max_width), fg="magenta", bold=True) + " " + purltext[indx])
click.echo(click.style("RAISED > ", fg="green", bold=True) + str(len(purltext)) + " result(s) in " + str(duration)[0:3] + " seconds [" + self.obtntime() + "]")
except wikipedia.exceptions.HTTPTimeoutError:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "Timeout occured while processing the query.")
except wikipedia.exceptions.RedirectError:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "Page title unexpectedly resolved to a redirect.")
except wikipedia.exceptions.PageError:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "Couldn't find the Wikipedia page for the query.")
except wikipedia.exceptions.DisambiguationError:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "The query resolves to a Disambiguation page.")
except wikipedia.exceptions.WikipediaException:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "Base Wikipedia exception class.")
except Exception:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "Exception occurred due to which results could not be displayed")
def getshort(self):
if self.srchqery is None:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "You do not seem to have provided a search query")
sys.exit()
else:
try:
strttime = time.monotonic()
purltext = wikipedia.page(self.srchqery).summary
stoptime = time.monotonic()
duration = stoptime - strttime
click.echo(click.style("RESULT > ", fg="green", bold=True) + click.style("SUMMARY > ", fg="blue", bold=True) + "\n" + purltext)
click.echo(click.style("RAISED > ", fg="green", bold=True) + "1 result in " + str(duration)[0:3] + " seconds [" + self.obtntime() + "]")
except wikipedia.exceptions.PageError:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "Couldn't find the Wikipedia page for the query.")
except wikipedia.exceptions.DisambiguationError:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "The query resolves to a Disambiguation page.")
except wikipedia.exceptions.RedirectError:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "Page title unexpectedly resolved to a redirect.")
except wikipedia.exceptions.HTTPTimeoutError:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "Timeout occured while processing the query.")
except wikipedia.exceptions.WikipediaException:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "Base Wikipedia exception class.")
except Exception:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "Exception occurred due to which results could not be displayed")
def getcreds(self):
if self.srchqery is None:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "You do not seem to have provided a search query")
sys.exit()
else:
try:
strttime = time.monotonic()
purltext = wikipedia.page(self.srchqery).references
stoptime = time.monotonic()
duration = stoptime - strttime
click.echo(click.style("RESULT > ", fg="green", bold=True) + click.style("REFERENCES > ", fg="blue", bold=True))
max_width=len(str(len(purltext)))+1
for indx in range(len(purltext)):
click.echo(click.style(f"#{indx+1}".rjust(max_width), fg="magenta", bold=True) + " " + purltext[indx])
click.echo(click.style("RAISED > ", fg="green", bold=True) + str(len(purltext)) + " result(s) in " + str(duration)[0:3] + " seconds [" + self.obtntime() + "]")
except wikipedia.exceptions.PageError:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "Couldn't find the Wikipedia page for the query.")
except wikipedia.exceptions.DisambiguationError:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "The query resolves to a Disambiguation page.")
except wikipedia.exceptions.RedirectError:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "Page title unexpectedly resolved to a redirect.")
except wikipedia.exceptions.HTTPTimeoutError:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "Timeout occured while processing the query.")
except wikipedia.exceptions.WikipediaException:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "Base Wikipedia exception class.")
except Exception:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "Exception occurred due to which results could not be displayed")
def getimage(self):
if self.srchqery is None:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "You do not seem to have provided a search query")
sys.exit()
else:
try:
strttime = time.monotonic()
purltext = wikipedia.page(self.srchqery).images
stoptime = time.monotonic()
duration = stoptime - strttime
click.echo(click.style("RESULT > ", fg="green", bold=True) + click.style("IMAGES > ", fg="blue", bold=True))
max_width = len(str(len(purltext)))+1
for indx in range(len(purltext)):
click.echo(click.style(f"#{indx+1}".rjust(max_width), fg="magenta", bold=True) + " " + purltext[indx])
click.echo(click.style("RAISED > ", fg="green", bold=True) + str(len(purltext)) + " result(s) in " + str(duration)[0:3] + " seconds [" + self.obtntime() + "]")
except wikipedia.exceptions.PageError:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "Couldn't find the Wikipedia page for the query.")
except wikipedia.exceptions.DisambiguationError:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "The query resolves to a Disambiguation page.")
except wikipedia.exceptions.RedirectError:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "Page title unexpectedly resolved to a redirect.")
except wikipedia.exceptions.HTTPTimeoutError:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "Timeout occured while processing the query.")
except wikipedia.exceptions.WikipediaException:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "Base Wikipedia exception class.")
except Exception:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "Exception occurred due to which results could not be displayed")
def getpgeid(self):
if self.srchqery is None:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "You do not seem to have provided a search query")
sys.exit()
else:
try:
strttime = time.monotonic()
purltext = wikipedia.page(self.srchqery).pageid
stoptime = time.monotonic()
duration = stoptime - strttime
click.echo(click.style("RESULT > ", fg="green", bold=True) + click.style("PAGEID > ", fg="blue", bold=True) + purltext)
click.echo(click.style("RAISED > ", fg="green", bold=True) + "1 result in " + str(duration)[0:3] + " seconds [" + self.obtntime() + "]")
except wikipedia.exceptions.PageError:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "Couldn't find the Wikipedia page for the query.")
except wikipedia.exceptions.DisambiguationError:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "The query resolves to a Disambiguation page.")
except wikipedia.exceptions.RedirectError:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "Page title unexpectedly resolved to a redirect.")
except wikipedia.exceptions.HTTPTimeoutError:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "Timeout occured while processing the query.")
except wikipedia.exceptions.WikipediaException:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "Base Wikipedia exception class.")
except Exception:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "Exception occurred due to which results could not be displayed")
def getrevid(self):
if self.srchqery is None:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "You do not seem to have provided a search query")
sys.exit()
else:
try:
strttime = time.monotonic()
purltext = wikipedia.page(self.srchqery).revision_id
stoptime = time.monotonic()
duration = stoptime - strttime
click.echo(click.style("RESULT > ", fg="green", bold=True) + click.style("REVISIONID > ", fg="blue", bold=True) + str(purltext))
click.echo(click.style("RAISED > ", fg="green", bold=True) + "1 result in " + str(duration)[0:3] + " seconds [" + self.obtntime() + "]")
except wikipedia.exceptions.PageError:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "Couldn't find the Wikipedia page for the query.")
except wikipedia.exceptions.DisambiguationError:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "The query resolves to a Disambiguation page.")
except wikipedia.exceptions.RedirectError:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "Page title unexpectedly resolved to a redirect.")
except wikipedia.exceptions.HTTPTimeoutError:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "Timeout occured while processing the query.")
except wikipedia.exceptions.WikipediaException:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "Base Wikipedia exception class.")
except Exception:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "Exception occurred due to which results could not be displayed")
def getprtid(self):
if self.srchqery is None:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "You do not seem to have provided a search query")
sys.exit()
else:
try:
strttime = time.monotonic()
purltext = wikipedia.page(self.srchqery).parent_id
stoptime = time.monotonic()
duration = stoptime - strttime
click.echo(click.style("RESULT > ", fg="green", bold=True) + click.style("PARENTID > ", fg="blue", bold=True) + str(purltext))
click.echo(click.style("RAISED > ", fg="green", bold=True) + "1 result in " + str(duration)[0:3] + " seconds [" + self.obtntime() + "]")
except wikipedia.exceptions.PageError:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "Couldn't find the Wikipedia page for the query.")
except wikipedia.exceptions.DisambiguationError:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "The query resolves to a Disambiguation page.")
except wikipedia.exceptions.RedirectError:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "Page title unexpectedly resolved to a redirect.")
except wikipedia.exceptions.HTTPTimeoutError:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "Timeout occured while processing the query.")
except wikipedia.exceptions.WikipediaException:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "Base Wikipedia exception class.")
except Exception:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "Exception occurred due to which results could not be displayed")
def getdcont(self):
if self.srchqery is None:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "You do not seem to have provided a search query")
sys.exit()
else:
try:
strttime = time.monotonic()
purltext = wikipedia.page(self.srchqery).content
stoptime = time.monotonic()
duration = stoptime - strttime
purltext = self.prsehead(purltext)
click.echo(click.style("RESULT > ", fg="green", bold=True) + click.style("CONTENT > ", fg="blue", bold=True) + "\n" + purltext)
click.echo(click.style("RAISED > ", fg="green", bold=True) + "1 result in " + str(duration)[0:3] + " seconds [" + self.obtntime() + "]")
except wikipedia.exceptions.PageError:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "Couldn't find the Wikipedia page for the query.")
except wikipedia.exceptions.DisambiguationError:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "The query resolves to a Disambiguation page.")
except wikipedia.exceptions.RedirectError:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "Page title unexpectedly resolved to a redirect.")
except wikipedia.exceptions.HTTPTimeoutError:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "Timeout occured while processing the query.")
except wikipedia.exceptions.WikipediaException:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "Base Wikipedia exception class.")
except Exception:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "Exception occurred due to which results could not be displayed")
def getpgcat(self):
if self.srchqery is None:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "You do not seem to have provided a search query")
sys.exit()
else:
try:
strttime = time.monotonic()
purltext = wikipedia.page(self.srchqery).categories
stoptime = time.monotonic()
duration = stoptime - strttime
click.echo(click.style("RESULT > ", fg="green", bold=True) + click.style("CATEGORIES > ", fg="blue", bold=True))
max_width = len(str(len(purltext)))+1
for indx in range(len(purltext)):
click.echo(click.style(f"#{indx+1}".rjust(max_width), fg="magenta", bold=True) + " " + purltext[indx])
click.echo(click.style("RAISED > ", fg="green", bold=True) + str(len(purltext)) + " result(s) in " + str(duration)[0:3] + " seconds [" + self.obtntime() + "]")
except wikipedia.exceptions.PageError:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "Couldn't find the Wikipedia page for the query.")
except wikipedia.exceptions.DisambiguationError:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "The query resolves to a Disambiguation page.")
except wikipedia.exceptions.RedirectError:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "Page title unexpectedly resolved to a redirect.")
except wikipedia.exceptions.HTTPTimeoutError:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "Timeout occured while processing the query.")
except wikipedia.exceptions.WikipediaException:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "Base Wikipedia exception class.")
except Exception:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "Exception occurred due to which results could not be displayed")
def getitems(self):
if self.srchqery is None:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "You do not seem to have provided a search query")
sys.exit()
else:
try:
strttime = time.monotonic()
purltext = wikipedia.search(self.srchqery)
stoptime = time.monotonic()
duration = stoptime - strttime
click.echo(click.style("RESULT > ", fg="green", bold=True) + click.style("SEARCH > ", fg="blue", bold=True))
max_width = len(str(len(purltext)))+1
for indx in range(len(purltext)):
click.echo(click.style(f"#{indx+1}".rjust(max_width), fg="magenta", bold=True) + " " + purltext[indx])
click.echo(click.style("RAISED > ", fg="green", bold=True) + str(len(purltext)) + " result(s) in " + str(duration)[0:3] + " seconds [" + self.obtntime() + "]")
except wikipedia.exceptions.PageError:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "Couldn't find the Wikipedia page for the query.")
except wikipedia.exceptions.DisambiguationError:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "The query resolves to a Disambiguation page.")
except wikipedia.exceptions.RedirectError:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "Page title unexpectedly resolved to a redirect.")
except wikipedia.exceptions.HTTPTimeoutError:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "Timeout occured while processing the query.")
except wikipedia.exceptions.WikipediaException:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "Base Wikipedia exception class.")
except Exception:
click.echo(click.style("CAVEAT > ", fg="red", bold=True) + "Exception occurred due to which results could not be displayed")
def wkdonate(self):
click.echo(click.style("THANKS > ", fg="magenta", bold=True) + "for considering donating to the initiative")
wikipedia.donate()
@click.command()
@click.option("-u", "--getpgurl", "wkaction", flag_value="getpgurl", help="Get page URL if such page exists", required=True)
@click.option("-t", "--gettitle", "wkaction", flag_value="gettitle", help="Get page title if such page exists", required=True)
@click.option("-h", "--savehtml", "wkaction", flag_value="savehtml", help="Save page HTML to a file", required=True)
@click.option("-l", "--getlinks", "wkaction", flag_value="getlinks", help="Get the list of links available", required=True)
@click.option("-s", "--getshort", "wkaction", flag_value="getshort", help="Get page summary if such page exists", required=True)
@click.option("-r", "--getcreds", "wkaction", flag_value="getcreds", help="Get the list of references available", required=True)
@click.option("-i", "--getimage", "wkaction", flag_value="getimage", help="Get the list of images available", required=True)
@click.option("-d", "--getpgeid", "wkaction", flag_value="getpgeid", help="Get page identity if such page exists", required=True)
@click.option("-v", "--getrevid", "wkaction", flag_value="getrevid", help="Get revision identity if such page exists", required=True)
@click.option("-p", "--getprtid", "wkaction", flag_value="getprtid", help="Get parent identity if such page exists", required=True)
@click.option("-c", "--getdcont", "wkaction", flag_value="getdcont", help="Get page content if such page exists", required=True)
@click.option("-g", "--getpgcat", "wkaction", flag_value="getpgcat", help="Get page category if such page exists", required=True)
@click.option("-e", "--getitems", "wkaction", flag_value="getitems", help="Get list of search results", required=True)
@click.option("-o", "--wkdonate", "wkaction", flag_value="wkdonate", help="Donate to the Wikimedia project", required=True)
@click.option("-q", "--srchqery", "srchqery", help="Enter the query you wish to search for")
@click.version_option(version="09102020", prog_name="Wisdom CLI by t0xic0der")
def mainfunc(srchqery, wkaction):
click.echo(click.style("WISDOM > ", fg="green", bold=True) + "Welcome " + getpass.getuser() + ", please wait while the results are obtained.")
wikiobjc = wikiclss(srchqery)
if wkaction == "getpgurl": wikiobjc.getpgurl()
elif wkaction == "gettitle": wikiobjc.gettitle()
elif wkaction == "savehtml": wikiobjc.savehtml()
elif wkaction == "getlinks": wikiobjc.getlinks()
elif wkaction == "getshort": wikiobjc.getshort()
elif wkaction == "getcreds": wikiobjc.getcreds()
elif wkaction == "getimage": wikiobjc.getimage()
elif wkaction == "getpgeid": wikiobjc.getpgeid()
elif wkaction == "getrevid": wikiobjc.getrevid()
elif wkaction == "getprtid": wikiobjc.getprtid()
elif wkaction == "getdcont": wikiobjc.getdcont()
elif wkaction == "getpgcat": wikiobjc.getpgcat()
elif wkaction == "getitems": wikiobjc.getitems()
elif wkaction == "wkdonate": wikiobjc.wkdonate()
if __name__ == "__main__":
mainfunc()