Project/Project.py

changeset 583
08bc660d6a15
parent 570
43a680c5c8e6
child 585
f40889943c0a
equal deleted inserted replaced
582:6b19bd357000 583:08bc660d6a15
1216 if self.pfile is None: 1216 if self.pfile is None:
1217 return 1217 return
1218 1218
1219 fn, ext = os.path.splitext(os.path.basename(self.pfile)) 1219 fn, ext = os.path.splitext(os.path.basename(self.pfile))
1220 1220
1221 try: 1221 fn = os.path.join(self.getProjectManagementDir(), '{0}.e4t'.format(fn))
1222 if ext.lower() == ".e4pz": 1222 f = QFile(fn)
1223 fn = os.path.join(self.getProjectManagementDir(), '{0}.e4tz'.format(fn)) 1223 ok = f.open(QIODevice.WriteOnly)
1224 try: 1224 if not ok:
1225 import gzip
1226 except ImportError:
1227 E5MessageBox.critical(self.ui,
1228 self.trUtf8("Save tasks"),
1229 self.trUtf8("""Compressed tasks files not supported."""
1230 """ The compression library is missing."""))
1231 return
1232 f = io.StringIO()
1233 else:
1234 fn = os.path.join(self.getProjectManagementDir(), '{0}.e4t'.format(fn))
1235 f = open(fn, "w", encoding = "utf-8")
1236
1237 TasksWriter(f, True, os.path.splitext(os.path.basename(fn))[0]).writeXML()
1238
1239 if fn.lower().endswith("e4tz"):
1240 g = gzip.open(fn, "wb")
1241 g.write(f.getvalue().encode("utf-8"))
1242 g.close()
1243 f.close()
1244
1245 except IOError:
1246 E5MessageBox.critical(self.ui, 1225 E5MessageBox.critical(self.ui,
1247 self.trUtf8("Save tasks"), 1226 self.trUtf8("Save tasks"),
1248 self.trUtf8("<p>The tasks file <b>{0}</b> could not be written.</p>") 1227 self.trUtf8("<p>The tasks file <b>{0}</b> could not be written.</p>")
1249 .format(fn)) 1228 .format(fn))
1229 return
1230
1231 TasksWriter(f, True, os.path.splitext(os.path.basename(fn))[0]).writeXML()
1232 f.close()
1250 1233
1251 def __readDebugProperties(self, quiet = False): 1234 def __readDebugProperties(self, quiet = False):
1252 """ 1235 """
1253 Private method to read in the project debugger properties file (.e4d) 1236 Private method to read in the project debugger properties file (.e4d)
1254 1237

eric ide

mercurial