Project/Project.py

changeset 5225
b1ea0ba84ffc
parent 5117
1faa0780ae1d
child 5230
3f61c5e46116
--- a/Project/Project.py	Mon Oct 10 19:23:38 2016 +0200
+++ b/Project/Project.py	Mon Oct 10 20:09:29 2016 +0200
@@ -9,7 +9,7 @@
 
 from __future__ import unicode_literals
 try:
-    str = unicode
+    str = unicode   # __IGNORE_EXCEPTION__
 except NameError:
     pass
 
@@ -4776,8 +4776,27 @@
         
         @param snapshot flag indicating a snapshot archive (boolean)
         """
-        pkglist = os.path.join(self.ppath, "PKGLIST")
-        if not os.path.exists(pkglist):
+        pkglists = [os.path.basename(f) for f in
+                    glob.glob(os.path.join(self.ppath, "PKGLIST*"))]
+        if len(pkglists) == 1:
+            pkglist = os.path.join(self.ppath, pkglists[0])
+        elif len(pkglists) > 1:
+            pkglist, ok = QInputDialog.getItem(
+                None,
+                self.tr("Create Plugin Archive"),
+                self.tr("Select a package list file:"),
+                pkglists,
+                0, False)
+            if not ok or not pkglist:
+                E5MessageBox.critical(
+                    self.ui,
+                    self.tr("Create Plugin Archive"),
+                    self.tr("""<p>No package list file selected. """
+                            """Aborting...</p>"""))
+                return
+            else:
+                pkglist = os.path.join(self.ppath, pkglist)
+        else:
             E5MessageBox.critical(
                 self.ui,
                 self.tr("Create Plugin Archive"),
@@ -4798,7 +4817,6 @@
             pkglistFile = open(pkglist, "r", encoding="utf-8")
             names = pkglistFile.read()
             pkglistFile.close()
-            names = sorted(names.splitlines())
         except IOError as why:
             E5MessageBox.critical(
                 self.ui,
@@ -4808,8 +4826,24 @@
                     """<p>Reason: {0}</p>""").format(str(why)))
             return
         
-        archive = os.path.join(
-            self.ppath, self.pdata["MAINSCRIPT"].replace(".py", ".zip"))
+        lines = names.splitlines()
+        archiveName = ""
+        names = []
+        for line in lines:
+            if line.startswith(";"):
+                # it's a comment possibly containing a directive
+                # supported directives are:
+                # - archive_name= defines the name of the archive
+                if line[1:].strip().startswith("archive_name="):
+                    archiveName = line[1:].split("=")[1]
+            else:
+                names.append(line)
+        names = sorted(names)
+        if archiveName:
+            archive = os.path.join(self.ppath, archiveName)
+        else:
+            archive = os.path.join(
+                self.ppath, self.pdata["MAINSCRIPT"].replace(".py", ".zip"))
         try:
             archiveFile = zipfile.ZipFile(archive, "w")
         except IOError as why:

eric ide

mercurial