@@ -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
145145class 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