Skip to content

Commit ab117cc

Browse files
committed
Fix Codacy static code issue
1 parent 0870b30 commit ab117cc

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

src/arguments/search.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
from .error import SearchError
88
from .utility import Utility
9+
from .utility import Playbook
910
from .save import SaveSearchResults
1011
from .update import UpdateApplication
1112
from .api_test import ApiTesting
@@ -30,14 +31,15 @@ def __init__(self, arguments):
3031
self.arguments = arguments
3132
self.utility_object = Utility()
3233
self.api_test_object = ApiTesting()
34+
self.playbook_object = Playbook()
3335

3436
def search_args(self):
3537
if self.arguments.search:
3638
self.search_for_results()
3739
elif self.arguments.file:
3840
self.search_for_results(True)
3941
elif self.arguments.playbook:
40-
self.utility_object.display_playbook()
42+
self.playbook_object.display_panel()
4143
elif self.arguments.new:
4244
url = "https://stackoverflow.com/questions/ask"
4345
if type(self.arguments.new) == str:

src/arguments/utility.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def playbook_content(self):
6868
def playbook_content(self, value):
6969
"""
7070
Saves playbook in the following format
71-
{
71+
{
7272
time_of_update: unix,
7373
items_stackoverflow:
7474
[
@@ -83,10 +83,9 @@ def playbook_content(self, value):
8383
]
8484
}
8585
"""
86-
if type(value) == dict:
86+
if isinstance(value, dict):
8787
with open(self.playbook_path, 'w') as playbook:
8888
json.dump(value, playbook, ensure_ascii=False)
89-
pass
9089
else:
9190
raise ValueError("value should be of type dict")
9291

@@ -96,10 +95,10 @@ def is_question_in_playbook(self, question_id):
9695
if int(entry['question_id']) == int(question_id):
9796
return True
9897
return False
99-
98+
10099
def add_to_playbook(self, stackoverflow_object, question_id):
101100
"""
102-
Receives a QuestionsPanelStackoverflow object and
101+
Receives a QuestionsPanelStackoverflow object and
103102
saves data of a particular question into playbook
104103
"""
105104
if self.is_question_in_playbook(question_id):
@@ -136,11 +135,12 @@ def display_panel(self):
136135
if(len(playbook_data['items_stackoverflow']) == 0):
137136
SearchError("You have no entries in the playbook", "Browse and save entries in playbook with 'p' key")
138137
sys.exit()
138+
# Creates QuestionPanelStackoverflow object, populates its question_data and answer_data and displays it
139139
question_panel = QuestionsPanelStackoverflow()
140140
for item in playbook_data['items_stackoverflow']:
141141
question_panel.questions_data.append( [item['question_title'], item['question_id'], item['question_link']] )
142142
question_panel.answer_data[item['question_id']] = item['answer_body']
143-
question_panel.display_panel(playbook=True)
143+
question_panel.display_panel([], playbook=True)
144144

145145
class QuestionsPanelStackoverflow():
146146
def __init__(self):
@@ -235,8 +235,8 @@ def navigate_questions_panel(self, playbook=False):
235235
elif(question_menu.chosen_accept_key == 'd' and playbook):
236236
self.playbook.delete_from_playbook(self, self.questions_data[options_index][1])
237237

238-
def display_panel(self, questions_list=[], playbook=False):
239-
if len(questions_list) != 0:
238+
def display_panel(self, questions_list, playbook=False):
239+
if not playbook:
240240
self.populate_question_data(questions_list)
241241
self.populate_answer_data(questions_list)
242242
self.navigate_questions_panel(playbook=playbook)
@@ -309,10 +309,6 @@ def get_ans(self, questions_list):
309309
stackoverflow_panel.display_panel(questions_list)
310310
# Support for reddit searching can also be implemented from here
311311

312-
def display_playbook(self):
313-
playbook = Playbook()
314-
playbook.display_panel()
315-
316312
# Get an access token and extract to a JSON file "access_token.json"
317313
@classmethod
318314
def setCustomKey(self):

0 commit comments

Comments
 (0)