Skip to content

Commit 59c5378

Browse files
committed
Changed code to follow strict PEP8
1 parent 6b37739 commit 59c5378

File tree

2 files changed

+40
-23
lines changed

2 files changed

+40
-23
lines changed

src/arguments/search.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,5 +93,5 @@ def search_for_results(self, save=False):
9393
if save:
9494
filename = SaveSearchResults(data)
9595
print(
96-
colored(f"\U0001F604 Answers successfully saved into {filename}",
97-
"green"))
96+
colored("\U0001F604 Answers successfully saved into" +\
97+
filename, "green"))

src/arguments/utility.py

Lines changed: 38 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,10 @@
3636

3737
class Playbook():
3838
def __init__(self):
39-
self.linux_path = "/home/{}/Documents/dynamic".format(os.getenv('USER'))
40-
self.mac_path = "/Users/{}/Documents/dynamic".format(os.getenv('USER'))
39+
self.linux_path = "/home/{}/Documents/dynamic".\
40+
format(os.getenv('USER'))
41+
self.mac_path = "/Users/{}/Documents/dynamic".\
42+
format(os.getenv('USER'))
4143
self.file_name = 'dynamic_playbook.json'
4244
self.key = 'DYNAMIC'
4345

@@ -49,9 +51,11 @@ def playbook_path(self):
4951
"""
5052
if not os.getenv(self.key):
5153
if(sys.platform=='linux'):
52-
os.environ[self.key] = os.path.join(self.linux_path, self.file_name)
54+
os.environ[self.key] = os.path.\
55+
join(self.linux_path, self.file_name)
5356
elif(sys.platform=='darwin'):
54-
os.environ[self.key] = os.path.join(self.mac_path, self.file_name)
57+
os.environ[self.key] = os.path.\
58+
join(self.mac_path, self.file_name)
5559
return os.getenv(self.key)
5660

5761
@property
@@ -106,7 +110,8 @@ def add_to_playbook(self, stackoverflow_object, question_id):
106110
]
107111
"""
108112
if self.is_question_in_playbook(question_id):
109-
console.print("[red] Question is already in the playbook, No need to add")
113+
console.print("[red] Question is already in the playbook," +
114+
"No need to add")
110115
return
111116
for question in stackoverflow_object.questions_data:
112117
if(int(question[1])==int(question_id)):
@@ -118,7 +123,8 @@ def add_to_playbook(self, stackoverflow_object, question_id):
118123
'question_id': int(question_id),
119124
'question_title': question[0],
120125
'question_link': question[2],
121-
'answer_body': stackoverflow_object.answer_data[int(question_id)]
126+
'answer_body': stackoverflow_object.\
127+
answer_data[int(question_id)]
122128
})
123129
self.playbook_content = content
124130
console.print("[green] Question added to the playbook")
@@ -188,8 +194,10 @@ def populate_question_data(self, questions_list):
188194
def populate_answer_data(self, questions_list):
189195
"""
190196
Function to populate answer data property
191-
Creates batch request to stackexchange API to get ans of questions with
192-
question id in the list. Stores the returned data data in the following format:
197+
Creates batch request to stackexchange API
198+
to get ans of questions with question id
199+
in the list. Stores the returned data data
200+
in the following format:
193201
dict( question_id:list( body, link ) )
194202
"""
195203
with console.status("Searching answers..."):
@@ -216,7 +224,8 @@ def return_formatted_ans(self, ques_id):
216224
body_markdown = self.answer_data[int(ques_id)]
217225
body_markdown = str(body_markdown)
218226
xml_markup_replacement = [("&amp;", "&"), ("&lt;", "<"), ("&gt;", ">"),
219-
("&quot;", "\""), ("&apos;", "\'"), ("&#39;", "\'")]
227+
("&quot;", "\""), ("&apos;", "\'"),
228+
("&#39;", "\'")]
220229
for convert_from, convert_to in xml_markup_replacement:
221230
body_markdown = body_markdown.replace(convert_from, convert_to)
222231
width = os.get_terminal_size().columns
@@ -228,7 +237,8 @@ def return_formatted_ans(self, ques_id):
228237
if not('UTF' in locale.getlocale()[1]):
229238
box_replacement = [("─", "-"), ("═","="), ("║","|"), ("│", "|"),
230239
('┌', '+'), ("└", "+"), ("┐", "+"), ("┘", "+"),
231-
("╔", "+"), ("╚", "+"), ("╗","+"), ("╝", "+"), ("•","*")]
240+
("╔", "+"), ("╚", "+"), ("╗","+"), ("╝", "+"),
241+
("•","*")]
232242
for convert_from, convert_to in box_replacement:
233243
highlighted = highlighted.replace(convert_from, convert_to)
234244
return highlighted
@@ -244,12 +254,13 @@ def navigate_questions_panel(self, playbook=False):
244254
instructions = ". Press 'p' to save in playbook"
245255
keys = ('enter', 'p')
246256
console.rule('[bold blue] {}'.format(message), style="bold red")
247-
console.print("[yellow] Use arrow keys to navigate. \
248-
'q' or 'Esc' to quit. 'Enter' to open in a browser" +
257+
console.print("[yellow] Use arrow keys to navigate." +
258+
"'q' or 'Esc' to quit. 'Enter' to open in a browser" +
249259
instructions)
250260
console.print()
251261
options = ["|".join(map(str, question)) for question in self.questions_data]
252-
question_menu = TerminalMenu(options, preview_command=self.return_formatted_ans,
262+
question_menu = TerminalMenu(options,
263+
preview_command=self.return_formatted_ans,
253264
preview_size=0.75, accept_keys=keys)
254265
quitting = False
255266
while not(quitting):
@@ -262,9 +273,11 @@ def navigate_questions_panel(self, playbook=False):
262273
if(question_menu.chosen_accept_key == 'enter'):
263274
webbrowser.open(question_link)
264275
elif(question_menu.chosen_accept_key == 'p'):
265-
self.playbook.add_to_playbook(self, self.questions_data[options_index][1])
276+
self.playbook.\
277+
add_to_playbook(self, self.questions_data[options_index][1])
266278
elif(question_menu.chosen_accept_key == 'd' and playbook):
267-
self.playbook.delete_from_playbook(self, self.questions_data[options_index][1])
279+
self.playbook.\
280+
delete_from_playbook(self, self.questions_data[options_index][1])
268281

269282
def display_panel(self, questions_list, playbook=False):
270283
if not playbook:
@@ -365,7 +378,8 @@ def setCustomKey(self):
365378

366379
# Create an OAuth session and open the auth_url in a browser
367380
# for the user to authenticate
368-
stackApps = OAuth2Session(client=MobileApplicationClient(client_id=client_id),
381+
stackApps = OAuth2Session(client=
382+
MobileApplicationClient(client_id=client_id),
369383
scope=scopes, redirect_uri=redirect_uri)
370384
auth_url, state = stackApps.authorization_url(authorization_url)
371385

@@ -375,18 +389,21 @@ def setCustomKey(self):
375389
driver = webdriver.Chrome(ChromeDriverManager().install())
376390
except ValueError:
377391
try:
378-
driver = webdriver.Firefox(executable_path=GeckoDriverManager().install())
392+
driver = webdriver.Firefox(executable_path=
393+
GeckoDriverManager().install())
379394
except ValueError:
380395
try:
381-
driver = webdriver.Edge(EdgeChromiumDriverManager().install())
396+
driver = webdriver.Edge(EdgeChromiumDriverManager().\
397+
install())
382398
except ValueError:
383-
print("You do not have one of these supported browsers: \
384-
Chrome, Firefox, Edge")
399+
print("You do not have one of these supported browsers:" +
400+
"Chrome, Firefox, Edge")
385401

386402
# Open auth_url in one of the supported browsers
387403
driver.get(auth_url)
388404

389-
# Close the window after 20s (Assuming that the user logs in within 30 seconds)
405+
# Close the window after 20s
406+
# (Assuming that the user logs in within 30 seconds)
390407
time.sleep(30)
391408
# Close the windows as soon as authorization is done
392409
try:

0 commit comments

Comments
 (0)