Project/Project.py

branch
5_3_x
changeset 2522
250b92d6f3f9
parent 2513
c4c3050ae363
child 2539
05a2752b476c
equal deleted inserted replaced
2520:d226e801d308 2522:250b92d6f3f9
4247 newline = None 4247 newline = None
4248 else: 4248 else:
4249 newline = self.getEolString() 4249 newline = self.getEolString()
4250 pkglistFile = open(pkglist, "w", encoding="utf-8", newline=newline) 4250 pkglistFile = open(pkglist, "w", encoding="utf-8", newline=newline)
4251 pkglistFile.write("\n".join(lst)) 4251 pkglistFile.write("\n".join(lst))
4252 pkglistFile.write("\n") # ensure the file ends with an empty line
4252 pkglistFile.close() 4253 pkglistFile.close()
4253 except IOError as why: 4254 except IOError as why:
4254 E5MessageBox.critical(self.ui, 4255 E5MessageBox.critical(self.ui,
4255 self.trUtf8("Create Package List"), 4256 self.trUtf8("Create Package List"),
4256 self.trUtf8("""<p>The file <b>PKGLIST</b> could not be created.</p>""" 4257 self.trUtf8("""<p>The file <b>PKGLIST</b> could not be created.</p>"""
4305 """not be created.</p>""" 4306 """not be created.</p>"""
4306 """<p>Reason: {1}</p>""").format(archive, str(why))) 4307 """<p>Reason: {1}</p>""").format(archive, str(why)))
4307 return 4308 return
4308 4309
4309 for name in names: 4310 for name in names:
4310 try: 4311 if name:
4311 self.__createZipDirEntries(os.path.split(name)[0], archiveFile) 4312 try:
4312 if snapshot and name == self.pdata["MAINSCRIPT"][0]: 4313 self.__createZipDirEntries(os.path.split(name)[0], archiveFile)
4313 snapshotSource, version = self.__createSnapshotSource( 4314 if snapshot and name == self.pdata["MAINSCRIPT"][0]:
4314 os.path.join(self.ppath, self.pdata["MAINSCRIPT"][0])) 4315 snapshotSource, version = self.__createSnapshotSource(
4315 archiveFile.writestr(name, snapshotSource)
4316 else:
4317 archiveFile.write(os.path.join(self.ppath, name), name)
4318 if name == self.pdata["MAINSCRIPT"][0]:
4319 version = self.__pluginExtractVersion(
4320 os.path.join(self.ppath, self.pdata["MAINSCRIPT"][0])) 4316 os.path.join(self.ppath, self.pdata["MAINSCRIPT"][0]))
4321 except OSError as why: 4317 archiveFile.writestr(name, snapshotSource)
4322 E5MessageBox.critical(self.ui, 4318 else:
4323 self.trUtf8("Create Plugin Archive"), 4319 archiveFile.write(os.path.join(self.ppath, name), name)
4324 self.trUtf8("""<p>The file <b>{0}</b> could not be stored """ 4320 if name == self.pdata["MAINSCRIPT"][0]:
4325 """in the archive. Ignoring it.</p>""" 4321 version = self.__pluginExtractVersion(
4326 """<p>Reason: {1}</p>""")\ 4322 os.path.join(self.ppath, self.pdata["MAINSCRIPT"][0]))
4327 .format(os.path.join(self.ppath, name), str(why))) 4323 except OSError as why:
4324 E5MessageBox.critical(self.ui,
4325 self.trUtf8("Create Plugin Archive"),
4326 self.trUtf8("""<p>The file <b>{0}</b> could not be stored """
4327 """in the archive. Ignoring it.</p>"""
4328 """<p>Reason: {1}</p>""")\
4329 .format(os.path.join(self.ppath, name), str(why)))
4328 archiveFile.writestr("VERSION", version.encode("utf-8")) 4330 archiveFile.writestr("VERSION", version.encode("utf-8"))
4329 archiveFile.close() 4331 archiveFile.close()
4330 4332
4331 if not archive in self.pdata["OTHERS"]: 4333 if not archive in self.pdata["OTHERS"]:
4332 self.appendFile(archive) 4334 self.appendFile(archive)

eric ide

mercurial