diff toolfactory/rgToolFactory2.py @ 111:223b78754735 draft

Uploaded
author fubar
date Sun, 29 Nov 2020 07:51:53 +0000
parents ab2474035f81
children 5509dc4c1cf2
line wrap: on
line diff
--- a/toolfactory/rgToolFactory2.py	Sun Nov 29 06:16:34 2020 +0000
+++ b/toolfactory/rgToolFactory2.py	Sun Nov 29 07:51:53 2020 +0000
@@ -63,8 +63,8 @@
 <exit_code range="100:" level="debug" description="shite happens" />
 </stdio>"""
 
-# --input_files="$input_files~~~$CL~~~$input_formats~~~$input_label
-# ~~~$input_help"
+# --input_files="$intab.input_files~~~$intab.input_CL~~~$intab.input_formats\
+#~~~$intab.input_label~~~$intab.input_help"
 IPATHPOS = 0
 ICLPOS = 1
 IFMTPOS = 2
@@ -263,7 +263,7 @@
                 clsuffix.append(appendme)
                 xclsuffix.append(xappendme)
             for i, p in enumerate(self.outfiles):
-                if p[OOCLPOS] == "STDOUT":
+                if p[OCLPOS] == "STDOUT":
                     self.lastclredirect = [">", p[ONAMEPOS]]
                     self.lastxclredirect = [">", "$%s" % p[OCLPOS]]
                 else:
@@ -296,7 +296,7 @@
         tscript.write(self.script)
         tscript.close()
         self.escapedScript = [cheetah_escape(x) for x in rx]
-        self.spacedScript = [f"    {x}" for x in self.escapedScript]
+        self.spacedScript = [f"    {x}" for x in rx]
         art = "%s.%s" % (self.tool_name, self.executeme)
         artifact = open(art, "wb")
         artifact.write(bytes('\n'.join(self.escapedScript),'utf8'))
@@ -305,21 +305,23 @@
     def cleanuppar(self):
         """ positional parameters are complicated by their numeric ordinal"""
         for i, p in enumerate(self.infiles):
+            infp = copy.copy(p)
             if self.args.parampass == "positional":
-                assert p[
+                assert infp[
                     ICLPOS
                 ].isdigit(), "Positional parameters must be ordinal integers - got %s for %s" % (
-                    p[ICLPOS],
-                    p[ILABPOS],
+                    infp[ICLPOS],
+                    infp[ILABPOS],
                 )
-            p.append(p[ICLPOS])
-            if p[ICLPOS].isdigit() or self.args.parampass == "0":
+            icl = infp[ICLPOS]
+            infp.append(icl)
+            if infp[ICLPOS].isdigit() or self.args.parampass == "0":
                 scl = "input%d" % (i + 1)
-                p[ICLPOS] = scl
-            self.infiles[i] = p
+                infp[ICLPOS] = scl
+            self.infiles[i] = infp
         for i, p in enumerate(
             self.outfiles
-        ):  # trying to automagically gather using extensions
+        ):
             if self.args.parampass == "positional" and p[OCLPOS] != "STDOUT":
                 assert p[
                     OCLPOS
@@ -327,7 +329,7 @@
                     p[OCLPOS],
                     p[ONAMEPOS],
                 )
-            p.append(p[OCLPOS])
+            p.append(p[OCLPOS]) # keep copy
             if p[OCLPOS].isdigit() or p[OCLPOS] == "STDOUT":
                 scl = p[ONAMEPOS]
                 p[OCLPOS] = scl
@@ -412,19 +414,19 @@
 
     def doXMLparam(self):
         """flake8 made me do this..."""
-        for p in self.outfiles:
+        for p in self.outfiles: # --output_files "$otab.history_name~~~$otab.history_format~~~$otab.history_CL~~~$otab.history_test"
             newname, newfmt, newcl, test, oldcl = p
             test = test.strip()
             ndash = self.getNdash(newcl)
-            aparm = gxtp.OutputData(newcl, format=newfmt, num_dashes=ndash)
+            aparm = gxtp.OutputData(name=newname, format=newfmt, num_dashes=ndash, label=newcl)
             aparm.positional = self.is_positional
             if self.is_positional:
                 if oldcl == "STDOUT":
                     aparm.positional = 9999999
-                    aparm.command_line_override = "> $%s" % newcl
+                    aparm.command_line_override = "> $%s" % newname
                 else:
                     aparm.positional = int(oldcl)
-                    aparm.command_line_override = "$%s" % newcl
+                    aparm.command_line_override = "$%s" % newname
             self.toutputs.append(aparm)
             ld = None
             if test.strip() > "":
@@ -582,7 +584,7 @@
                         + [">300 lines - stuff deleted", "......"]
                         + scr[-100:]
                     )
-                scr.append('\n------\n')
+                scr.append('\n')
                 safertext = safertext + "\n".join(scr)
             self.newtool.help = safertext
         else:
@@ -843,6 +845,7 @@
                 category_ids=catID,
             )
             tid = res.get("id", None)
+            sto.write(f"#####create_repository {self.args.tool_name} tid={tid} res={res}\n")
         else:
             i = rnames.index(self.tool_name)
             tid = rids[i]
@@ -850,10 +853,10 @@
             res = ts.repositories.update_repository(
                 id=tid, tar_ball_path=self.newtarpath, commit_message=None
             )
-            sto.write(f"#####update res={res}\n")
+            sto.write(f"#####update res id {id} ={res}\n")
         except ConnectionError:
             sto.write(
-                "Probably no change to repository - bioblend shed upload failed\n"
+                "Is the toolshed running and the API key correct? Bioblend shed upload failed\n"
             )
         sto.close()