47 """ |
47 """ |
48 Private method to read the file containing the commit message and |
48 Private method to read the file containing the commit message and |
49 populate the dialog. |
49 populate the dialog. |
50 """ |
50 """ |
51 try: |
51 try: |
52 f = open(self.__fileName, "r") |
52 with open(self.__fileName, "r") as f: |
53 txt = f.read() |
53 txt = f.read() |
54 f.close() |
|
55 except (IOError, OSError) as err: |
54 except (IOError, OSError) as err: |
56 E5MessageBox.critical( |
55 E5MessageBox.critical( |
57 self, |
56 self, |
58 self.tr("Edit Commit Message"), |
57 self.tr("Edit Commit Message"), |
59 self.tr("""<p>The file <b>{0}</b> could not be read.</p>""" |
58 self.tr("""<p>The file <b>{0}</b> could not be read.</p>""" |
87 """ |
86 """ |
88 Private slot called by the buttonBox accepted signal. |
87 Private slot called by the buttonBox accepted signal. |
89 """ |
88 """ |
90 msg = self.messageEdit.toPlainText() |
89 msg = self.messageEdit.toPlainText() |
91 try: |
90 try: |
92 f = open(self.__fileName, "w") |
91 with open(self.__fileName, "w") as f: |
93 f.write(msg) |
92 f.write(msg) |
94 f.close() |
|
95 except (IOError, OSError) as err: |
93 except (IOError, OSError) as err: |
96 E5MessageBox.critical( |
94 E5MessageBox.critical( |
97 self, |
95 self, |
98 self.tr("Edit Commit Message"), |
96 self.tr("Edit Commit Message"), |
99 self.tr("""<p>The file <b>{0}</b> could not be read.</p>""" |
97 self.tr("""<p>The file <b>{0}</b> could not be read.</p>""" |