TimeTracker/TimeTracker.py

changeset 91
3051e6733cda
parent 89
e38b60832145
child 92
81b63c2dc40c
equal deleted inserted replaced
90:8b1587bfe06e 91:3051e6733cda
138 """ 138 """
139 if os.path.exists(self.__trackerFilePath): 139 if os.path.exists(self.__trackerFilePath):
140 try: 140 try:
141 with open(self.__trackerFilePath, "r", encoding="utf-8") as f: 141 with open(self.__trackerFilePath, "r", encoding="utf-8") as f:
142 data = f.read() 142 data = f.read()
143 except (IOError, OSError) as err: 143 except OSError as err:
144 E5MessageBox.critical( 144 E5MessageBox.critical(
145 self.__ui, 145 self.__ui,
146 self.tr("Read Time Tracker File"), 146 self.tr("Read Time Tracker File"),
147 self.tr("""<p>The time tracker file <b>{0}</b> could""" 147 self.tr("""<p>The time tracker file <b>{0}</b> could"""
148 """ not be read.</p><p>Reason: {1}</p>""") 148 """ not be read.</p><p>Reason: {1}</p>""")
187 try: 187 try:
188 with open(filePath, "w", encoding="utf-8") as f: 188 with open(filePath, "w", encoding="utf-8") as f:
189 for entry in entriesList: 189 for entry in entriesList:
190 if entry.isValid(): 190 if entry.isValid():
191 f.write(entry.toString() + "\n") 191 f.write(entry.toString() + "\n")
192 except (IOError, OSError) as err: 192 except OSError as err:
193 E5MessageBox.critical( 193 E5MessageBox.critical(
194 self.__ui, 194 self.__ui,
195 self.tr("Save Time Tracker File"), 195 self.tr("Save Time Tracker File"),
196 self.tr("""<p>The time tracker file <b>{0}</b> could""" 196 self.tr("""<p>The time tracker file <b>{0}</b> could"""
197 """ not be saved.</p><p>Reason: {1}</p>""") 197 """ not be saved.</p><p>Reason: {1}</p>""")
204 @param fname name of the file to import (string) 204 @param fname name of the file to import (string)
205 """ 205 """
206 try: 206 try:
207 with open(fname, "r", encoding="utf-8") as f: 207 with open(fname, "r", encoding="utf-8") as f:
208 data = f.read() 208 data = f.read()
209 except (IOError, OSError) as err: 209 except OSError as err:
210 E5MessageBox.critical( 210 E5MessageBox.critical(
211 self.__ui, 211 self.__ui,
212 self.tr("Import Time Tracker File"), 212 self.tr("Import Time Tracker File"),
213 self.tr("""<p>The time tracker file <b>{0}</b> could""" 213 self.tr("""<p>The time tracker file <b>{0}</b> could"""
214 """ not be read.</p><p>Reason: {1}</p>""") 214 """ not be read.</p><p>Reason: {1}</p>""")

eric ide

mercurial