Skip to content

Commit 08a9a38

Browse files
committed
simplify try/except statement
1 parent 6ad6cde commit 08a9a38

1 file changed

Lines changed: 13 additions & 11 deletions

File tree

openmc_plotter/plotmodel.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,20 @@ def __init__(self, use_settings_pkl):
130130
self.subsequentViews = []
131131

132132
if use_settings_pkl and os.path.isfile('plot_settings.pkl'):
133-
try:
134-
with open('plot_settings.pkl', 'rb') as file:
133+
with open('plot_settings.pkl', 'rb') as file:
134+
try:
135135
data = pickle.load(file)
136+
except AttributeError:
137+
msg_box = QMessageBox()
138+
msg = "WARNING: previous plot settings are in an incompatible format. " +\
139+
"They will be ignored."
140+
msg_box.setText(msg)
141+
msg_box.setIcon(QMessageBox.Warning)
142+
msg_box.setStandardButtons(QMessageBox.Ok)
143+
msg_box.exec_()
144+
self.defaultView = self.getDefaultView()
136145

146+
else:
137147
# check GUI version
138148
if data['version'] != self.version:
139149
print("WARNING: previous plot settings are for a different "
@@ -157,15 +167,7 @@ def __init__(self, use_settings_pkl):
157167
self.statepoint = None
158168

159169
self.defaultView = PlotView(restore_view=view_ind)
160-
except AttributeError:
161-
msg_box = QMessageBox()
162-
msg = "WARNING: previous plot settings are in an incompatible format. " +\
163-
"They will be ignored."
164-
msg_box.setText(msg)
165-
msg_box.setIcon(QMessageBox.Warning)
166-
msg_box.setStandardButtons(QMessageBox.Ok)
167-
msg_box.exec_()
168-
self.defaultView = self.getDefaultView()
170+
169171
else:
170172
self.defaultView = self.getDefaultView()
171173

0 commit comments

Comments
 (0)