Mercurial > repos > fubar > tool_factory_2
diff toolfactory/rgToolFactory2.py @ 62:881bd8c81ac9 draft
Uploaded
author | fubar |
---|---|
date | Mon, 26 Oct 2020 02:51:54 +0000 |
parents | d21517a36db8 |
children | b3254219d4fb |
line wrap: on
line diff
--- a/toolfactory/rgToolFactory2.py Thu Oct 22 03:39:09 2020 +0000 +++ b/toolfactory/rgToolFactory2.py Mon Oct 26 02:51:54 2020 +0000 @@ -1,4 +1,3 @@ -#!/usr/bin/env python # rgToolFactory.py # see https://github.com/fubar2/toolfactory # @@ -325,15 +324,18 @@ """ no parameters - uses < and > for i/o """ aCL = self.cl.append - aCL("<") - aCL(self.infiles[0][IPATHPOS]) - aCL(">") - aCL(self.outfiles[0][OCLPOS]) aXCL = self.xmlcl.append - aXCL("<") - aXCL("$%s" % self.infiles[0][ICLPOS]) - aXCL(">") - aXCL("$%s" % self.outfiles[0][ONAMEPOS]) + + if len(self.infiles) > 0: + aCL("<") + aCL(self.infiles[0][IPATHPOS]) + aXCL("<") + aXCL("$%s" % self.infiles[0][ICLPOS]) + if len(self.outfiles) > 0: + aCL(">") + aCL(self.outfiles[0][OCLPOS]) + aXCL(">") + aXCL("$%s" % self.outfiles[0][ONAMEPOS]) def clpositional(self): # inputs in order then params @@ -482,37 +484,39 @@ def doNoXMLparam(self): """filter style package - stdin to stdout""" - alab = self.infiles[0][ILABPOS] - if len(alab) == 0: - alab = self.infiles[0][ICLPOS] - max1s = ( - "Maximum one input if parampass is 0 but multiple input files supplied - %s" - % str(self.infiles) - ) - assert len(self.infiles) == 1, max1s - newname = self.infiles[0][ICLPOS] - aninput = gxtp.DataParam( - newname, - optional=False, - label=alab, - help=self.infiles[0][IHELPOS], - format=self.infiles[0][IFMTPOS], - multiple=False, - num_dashes=0, - ) - aninput.command_line_override = "< $%s" % newname - aninput.positional = self.is_positional - self.tinputs.append(aninput) - tp = gxtp.TestParam(name=newname, value="%s_sample" % newname) - self.testparam.append(tp) - newname = self.outfiles[0][OCLPOS] - newfmt = self.outfiles[0][OFMTPOS] - anout = gxtp.OutputData(newname, format=newfmt, num_dashes=0) - anout.command_line_override = "> $%s" % newname - anout.positional = self.is_positional - self.toutputs.append(anout) - tp = gxtp.TestOutput(name=newname, value="%s_sample" % newname, format=newfmt) - self.testparam.append(tp) + if len(self.infiles) > 0: + alab = self.infiles[0][ILABPOS] + if len(alab) == 0: + alab = self.infiles[0][ICLPOS] + max1s = ( + "Maximum one input if parampass is 0 but multiple input files supplied - %s" + % str(self.infiles) + ) + assert len(self.infiles) == 1, max1s + newname = self.infiles[0][ICLPOS] + aninput = gxtp.DataParam( + newname, + optional=False, + label=alab, + help=self.infiles[0][IHELPOS], + format=self.infiles[0][IFMTPOS], + multiple=False, + num_dashes=0, + ) + aninput.command_line_override = "< $%s" % newname + aninput.positional = self.is_positional + self.tinputs.append(aninput) + tp = gxtp.TestParam(name=newname, value="%s_sample" % newname) + self.testparam.append(tp) + if len(self.outfiles > 0): + newname = self.outfiles[0][OCLPOS] + newfmt = self.outfiles[0][OFMTPOS] + anout = gxtp.OutputData(newname, format=newfmt, num_dashes=0) + anout.command_line_override = "> $%s" % newname + anout.positional = self.is_positional + self.toutputs.append(anout) + tp = gxtp.TestOutput(name=newname, value="%s_sample" % newname, format=newfmt) + self.testparam.append(tp) def makeXML(self): """ @@ -529,13 +533,13 @@ safertext = [html_escape(x) for x in helptext] if self.args.script_path: scrpt = self.script.split('\n') - scrpt.append("```\n") + scrpt.insert(0,"```\n") if len(scrpt) > 300: safertext = safertext + scrpt[:100] + ['>500 lines - stuff deleted','......'] + scrpt[-100:] else: safertext = safertext + scrpt safertext.append("\n```") - self.newtool.help = "".join([x for x in safertext]) + self.newtool.help = "\n".join([x for x in safertext]) else: self.newtool.help = ( "Please ask the tool author (%s) for help \ @@ -627,8 +631,14 @@ ste.close() retval = p.returncode else: # work around special case - stdin and write to stdout - sti = open(self.infiles[0][IPATHPOS], "rb") - sto = open(self.outfiles[0][ONAMEPOS], "wb") + if len(self.infiles) > 0: + sti = open(self.infiles[0][IPATHPOS], "rb") + else: + sti = sys.stdin + if len(self.outfiles) > 0: + sto = open(self.outfiles[0][ONAMEPOS], "wb") + else: + sto = sys.stdout p = subprocess.run(self.cl, shell=False, stdout=sto, stdin=sti) retval = p.returncode sto.close() @@ -695,7 +705,6 @@ cll = [ "planemo", "test", - "--skip_venv", "--galaxy_root", self.args.galaxy_root, "--update_test_data", @@ -703,7 +712,7 @@ ] else: cll = ["planemo", "test", "--galaxy_root", - self.args.galaxy_root, "--skip_venv", + self.args.galaxy_root, xreal,] p = subprocess.run( cll, shell=False, cwd=self.tooloutdir, stderr=tout, stdout=tout