eric6/UI/CompareDialog.py

changeset 7785
9978016560ec
parent 7781
607a6098cb44
child 7836
2f0d208b8137
equal deleted inserted replaced
7784:3257703e10c5 7785:9978016560ec
235 """ 235 """
236 Private slot to handle the Compare button press. 236 Private slot to handle the Compare button press.
237 """ 237 """
238 filename1 = self.file1Picker.text() 238 filename1 = self.file1Picker.text()
239 try: 239 try:
240 f1 = open(filename1, "r", encoding="utf-8") 240 with open(filename1, "r", encoding="utf-8") as f1:
241 lines1 = f1.readlines() 241 lines1 = f1.readlines()
242 f1.close()
243 except IOError: 242 except IOError:
244 E5MessageBox.critical( 243 E5MessageBox.critical(
245 self, 244 self,
246 self.tr("Compare Files"), 245 self.tr("Compare Files"),
247 self.tr( 246 self.tr(
249 .format(filename1)) 248 .format(filename1))
250 return 249 return
251 250
252 filename2 = self.file2Picker.text() 251 filename2 = self.file2Picker.text()
253 try: 252 try:
254 f2 = open(filename2, "r", encoding="utf-8") 253 with open(filename2, "r", encoding="utf-8") as f2:
255 lines2 = f2.readlines() 254 lines2 = f2.readlines()
256 f2.close()
257 except IOError: 255 except IOError:
258 E5MessageBox.critical( 256 E5MessageBox.critical(
259 self, 257 self,
260 self.tr("Compare Files"), 258 self.tr("Compare Files"),
261 self.tr( 259 self.tr(

eric ide

mercurial