Project/Project.py

changeset 2521
ca91f5ee1b23
parent 2512
290462cc60cb
child 2525
8b507a9a2d40
child 2537
0ff250733d45
equal deleted inserted replaced
2519:e245447026ad 2521:ca91f5ee1b23
4277 newline = None 4277 newline = None
4278 else: 4278 else:
4279 newline = self.getEolString() 4279 newline = self.getEolString()
4280 pkglistFile = open(pkglist, "w", encoding="utf-8", newline=newline) 4280 pkglistFile = open(pkglist, "w", encoding="utf-8", newline=newline)
4281 pkglistFile.write("\n".join(lst)) 4281 pkglistFile.write("\n".join(lst))
4282 pkglistFile.write("\n") # ensure the file ends with an empty line
4282 pkglistFile.close() 4283 pkglistFile.close()
4283 except IOError as why: 4284 except IOError as why:
4284 E5MessageBox.critical(self.ui, 4285 E5MessageBox.critical(self.ui,
4285 self.trUtf8("Create Package List"), 4286 self.trUtf8("Create Package List"),
4286 self.trUtf8("""<p>The file <b>PKGLIST</b> could not be created.</p>""" 4287 self.trUtf8("""<p>The file <b>PKGLIST</b> could not be created.</p>"""
4335 """not be created.</p>""" 4336 """not be created.</p>"""
4336 """<p>Reason: {1}</p>""").format(archive, str(why))) 4337 """<p>Reason: {1}</p>""").format(archive, str(why)))
4337 return 4338 return
4338 4339
4339 for name in names: 4340 for name in names:
4340 try: 4341 if name:
4341 self.__createZipDirEntries(os.path.split(name)[0], archiveFile) 4342 try:
4342 if snapshot and name == self.pdata["MAINSCRIPT"][0]: 4343 self.__createZipDirEntries(os.path.split(name)[0], archiveFile)
4343 snapshotSource, version = self.__createSnapshotSource( 4344 if snapshot and name == self.pdata["MAINSCRIPT"][0]:
4344 os.path.join(self.ppath, self.pdata["MAINSCRIPT"][0])) 4345 snapshotSource, version = self.__createSnapshotSource(
4345 archiveFile.writestr(name, snapshotSource)
4346 else:
4347 archiveFile.write(os.path.join(self.ppath, name), name)
4348 if name == self.pdata["MAINSCRIPT"][0]:
4349 version = self.__pluginExtractVersion(
4350 os.path.join(self.ppath, self.pdata["MAINSCRIPT"][0])) 4346 os.path.join(self.ppath, self.pdata["MAINSCRIPT"][0]))
4351 except OSError as why: 4347 archiveFile.writestr(name, snapshotSource)
4352 E5MessageBox.critical(self.ui, 4348 else:
4353 self.trUtf8("Create Plugin Archive"), 4349 archiveFile.write(os.path.join(self.ppath, name), name)
4354 self.trUtf8("""<p>The file <b>{0}</b> could not be stored """ 4350 if name == self.pdata["MAINSCRIPT"][0]:
4355 """in the archive. Ignoring it.</p>""" 4351 version = self.__pluginExtractVersion(
4356 """<p>Reason: {1}</p>""")\ 4352 os.path.join(self.ppath, self.pdata["MAINSCRIPT"][0]))
4357 .format(os.path.join(self.ppath, name), str(why))) 4353 except OSError as why:
4354 E5MessageBox.critical(self.ui,
4355 self.trUtf8("Create Plugin Archive"),
4356 self.trUtf8("""<p>The file <b>{0}</b> could not be stored """
4357 """in the archive. Ignoring it.</p>"""
4358 """<p>Reason: {1}</p>""")\
4359 .format(os.path.join(self.ppath, name), str(why)))
4358 archiveFile.writestr("VERSION", version.encode("utf-8")) 4360 archiveFile.writestr("VERSION", version.encode("utf-8"))
4359 archiveFile.close() 4361 archiveFile.close()
4360 4362
4361 if not archive in self.pdata["OTHERS"]: 4363 if not archive in self.pdata["OTHERS"]:
4362 self.appendFile(archive) 4364 self.appendFile(archive)

eric ide

mercurial