eric6/Plugins/VcsPlugins/vcsMercurial/HisteditExtension/HgHisteditPlanEditor.py

changeset 7785
9978016560ec
parent 7780
41420f82c0ac
child 7836
2f0d208b8137
equal deleted inserted replaced
7784:3257703e10c5 7785:9978016560ec
101 """ 101 """
102 Private method to read the file containing the edit plan and 102 Private method to read the file containing the edit plan and
103 populate the dialog. 103 populate the dialog.
104 """ 104 """
105 try: 105 try:
106 f = open(self.__fileName, "r") 106 with open(self.__fileName, "r") as f:
107 txt = f.read() 107 txt = f.read()
108 f.close()
109 except (IOError, OSError) as err: 108 except (IOError, OSError) as err:
110 E5MessageBox.critical( 109 E5MessageBox.critical(
111 self, 110 self,
112 self.tr("Edit Plan"), 111 self.tr("Edit Plan"),
113 self.tr("""<p>The file <b>{0}</b> could not be read.</p>""" 112 self.tr("""<p>The file <b>{0}</b> could not be read.</p>"""
237 """ 236 """
238 Private slot called by the buttonBox accepted signal. 237 Private slot called by the buttonBox accepted signal.
239 """ 238 """
240 text = self.__assembleEditPlan() 239 text = self.__assembleEditPlan()
241 try: 240 try:
242 f = open(self.__fileName, "w") 241 with open(self.__fileName, "w") as f:
243 f.write(text) 242 f.write(text)
244 f.close()
245 except (IOError, OSError) as err: 243 except (IOError, OSError) as err:
246 E5MessageBox.critical( 244 E5MessageBox.critical(
247 self, 245 self,
248 self.tr("Edit Plan"), 246 self.tr("Edit Plan"),
249 self.tr("""<p>The file <b>{0}</b> could not be read.</p>""" 247 self.tr("""<p>The file <b>{0}</b> could not be read.</p>"""

eric ide

mercurial