-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdriver.py
66 lines (56 loc) · 2 KB
/
driver.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
from utils.save_doc import DocSavar
# from utils.save_pdf import PdfSaver
from processor.content_scrapper import ContentScrapper
from utils.colored_printer import ColorPrinter
import warnings
import argparse
warnings.filterwarnings("ignore")
class MainDriver:
def __init__(self):
self.start_screen_file = open('prompts/start_screen.txt', 'r+')
self.connect_error_file = open('prompts/connection_error.txt', 'r+')
self.user_text_input = ''
self.content_sc = ContentScrapper()
self.doc = DocSavar()
# self.pdf_saver = PdfSaver()
# Remove the comment below to start user input
# self.article_maker()
def user_input(self):
try:
start_screen_text = self.start_screen_file.readlines()
ColorPrinter.print_colored(start_screen_text)
print("\n\033[0;31;48m Enter the topics separated by commas : \n")
user_text_input = input()
return user_text_input
except Exception as ex:
print("Error Encountered while taking user input")
print(ex)
def article_maker(self, input_string = ""):
try:
if input_string == "":
self.user_text_input = self.user_input()
else:
self.user_text_input = input_string
result_json = self.content_sc.get_content(self.user_text_input)
if result_json == 0:
connection_error_txt = self.connect_error_file.readlines()
ColorPrinter.print_colored(connection_error_txt)
return
f = self.doc.save_to_doc(result_json)
return f
# FIXME find another module to convert word to pdf as this module doesn't work in Linux
# This is the help wanted issue raised on Github
# self.pdf_saver.save_to_pdf(result_json)
except Exception as ex:
print("Error encountered while making article")
print(ex)
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="List of arguments required for launching automated EPOD2 Engine")
parser.add_argument('--config', default=None, help='CLI to start cli')
args = parser.parse_args()
mode = args.config
if mode == "CLI":
obj = MainDriver()
obj.article_maker()
else:
c = MainDriver()