eric6/ViewManager/ViewManager.py

changeset 7785
9978016560ec
parent 7775
4a1db75550bd
child 7824
096b3ebc1409
child 7836
2f0d208b8137
equal deleted inserted replaced
7784:3257703e10c5 7785:9978016560ec
6581 6581
6582 @param dictionaryFile file name of the dictionary to edit (string) 6582 @param dictionaryFile file name of the dictionary to edit (string)
6583 """ 6583 """
6584 if os.path.exists(dictionaryFile): 6584 if os.path.exists(dictionaryFile):
6585 try: 6585 try:
6586 f = open(dictionaryFile, "r", encoding="utf-8") 6586 with open(dictionaryFile, "r", encoding="utf-8") as f:
6587 data = f.read() 6587 data = f.read()
6588 f.close()
6589 except (IOError, OSError) as err: 6588 except (IOError, OSError) as err:
6590 E5MessageBox.critical( 6589 E5MessageBox.critical(
6591 self.ui, 6590 self.ui,
6592 QCoreApplication.translate( 6591 QCoreApplication.translate(
6593 'ViewManager', "Edit Spelling Dictionary"), 6592 'ViewManager', "Edit Spelling Dictionary"),
6611 .format(fileInfo), 6610 .format(fileInfo),
6612 self.ui) 6611 self.ui)
6613 if dlg.exec() == QDialog.Accepted: 6612 if dlg.exec() == QDialog.Accepted:
6614 data = dlg.getData() 6613 data = dlg.getData()
6615 try: 6614 try:
6616 f = open(dictionaryFile, "w", encoding="utf-8") 6615 with open(dictionaryFile, "w", encoding="utf-8") as f:
6617 f.write(data) 6616 f.write(data)
6618 f.close()
6619 except (IOError, OSError) as err: 6617 except (IOError, OSError) as err:
6620 E5MessageBox.critical( 6618 E5MessageBox.critical(
6621 self.ui, 6619 self.ui,
6622 QCoreApplication.translate( 6620 QCoreApplication.translate(
6623 'ViewManager', "Edit Spelling Dictionary"), 6621 'ViewManager', "Edit Spelling Dictionary"),

eric ide

mercurial