# HG changeset patch
# User fubar
# Date 1606624342 0
# Node ID e878bfc6b80cd4da1ead8cc67af9ba16b7c756fa
# Parent 18e616939a912115ec58041812b245c818c3efe7
Uploaded
diff -r 18e616939a91 -r e878bfc6b80c toolfactory/rgToolFactory2.py
--- a/toolfactory/rgToolFactory2.py Sat Nov 28 02:52:24 2020 +0000
+++ b/toolfactory/rgToolFactory2.py Sun Nov 29 04:32:22 2020 +0000
@@ -72,7 +72,7 @@
IHELPOS = 4
IOCLPOS = 5
-# --output_files "$otab.history_name~~~$otab.history_format~~~$otab.CL~~~otab.history_test
+# --output_files "$otab.history_name~~~$otab.history_format~~~$otab.history_CL~~~$otab.history_test"
ONAMEPOS = 0
OFMTPOS = 1
OCLPOS = 2
@@ -115,13 +115,17 @@
return '"%s"' % s
-html_escape_table = {"&": "&", ">": ">", "<": "<", "$": r"\$"}
-
+html_escape_table = {"&": "&", ">": ">", "<": "<", "$": r"\$","#":"#", "$":"$"}
+cheetah_escape_table = {"$": "\$","#":"\#"}
def html_escape(text):
"""Produce entities within text."""
return "".join(html_escape_table.get(c, c) for c in text)
+def cheetah_escape(text):
+ """Produce entities within text."""
+ return "".join(cheetah_escape_table.get(c, c) for c in text)
+
def html_unescape(text):
"""Revert entities within text. Multiple character targets so use replace"""
@@ -129,6 +133,8 @@
t = t.replace(">", ">")
t = t.replace("<", "<")
t = t.replace("\\$", "$")
+ t = t.replace("$","$")
+ t = t.replace("#","#")
return t
@@ -289,11 +295,11 @@
tscript = open(self.sfile, "w")
tscript.write(self.script)
tscript.close()
- self.indentedScript = " %s" % "\n".join([" %s" % html_escape(x) for x in rx])
- self.escapedScript = "%s" % "\n".join([" %s" % html_escape(x) for x in rx])
+ self.indentedScript = " %s" % "\n".join([" %s" % cheetah_escape(x) for x in rx])
+ self.escapedScript = "%s" % "\n".join([" %s" % cheetah_escape(x) for x in rx])
art = "%s.%s" % (self.tool_name, self.executeme)
artifact = open(art, "wb")
- artifact.write(bytes(self.script, "utf8"))
+ artifact.write(bytes(self.escapedScript, "utf8"))
artifact.close()
def cleanuppar(self):
@@ -408,6 +414,7 @@
"""flake8 made me do this..."""
for p in self.outfiles:
newname, newfmt, newcl, test, oldcl = p
+ test = test.strip()
ndash = self.getNdash(newcl)
aparm = gxtp.OutputData(newcl, format=newfmt, num_dashes=ndash)
aparm.positional = self.is_positional
@@ -419,24 +426,39 @@
aparm.positional = int(oldcl)
aparm.command_line_override = "$%s" % newcl
self.toutputs.append(aparm)
- usetest = None
ld = None
- if test > "":
+ if test.strip() > "":
if test.startswith("diff"):
- usetest = "diff"
+ c = "diff"
+ ld = 0
if test.split(":")[1].isdigit:
ld = int(test.split(":")[1])
- else:
- usetest = test
- tp = gxtp.TestOutput(
- name=newcl,
- value="%s_sample" % newcl,
- format=newfmt,
- compare=usetest,
- lines_diff=ld,
- delta=None,
- )
- self.testparam.append(tp)
+ tp = gxtp.TestOutput(
+ name=newcl,
+ value="%s_sample" % newcl,
+ format=newfmt,
+ compare= c,
+ lines_diff=ld,
+ )
+ elif test.startswith("sim_size"):
+ c = "sim_size"
+ tn = test.split(":")[1].strip()
+ if tn > '':
+ if '.' in tn:
+ delta = None
+ delta_frac = min(1.0,float(tn))
+ else:
+ delta = int(tn)
+ delta_frac = None
+ tp = gxtp.TestOutput(
+ name=newcl,
+ value="%s_sample" % newcl,
+ format=newfmt,
+ compare= c,
+ delta = delta,
+ delta_frac = delta_frac
+ )
+ self.testparam.append(tp)
for p in self.infiles:
newname = p[ICLPOS]
newfmt = p[IFMTPOS]
@@ -550,11 +572,12 @@
self.newtool.command_override = self.xmlcl
if self.args.help_text:
helptext = open(self.args.help_text, "r").readlines()
- safertext = [html_escape(x) for x in helptext]
- if False and self.args.script_path:
- scrp = self.script.split("\n")
- scrpt = [" %s" % x for x in scrp] # try to stop templating
- scrpt.insert(0, "```\n")
+ safertext = "\n".join([cheetah_escape(x) for x in helptext])
+ if self.args.script_path:
+ scr = self.script.split("\n")
+ scrp = [cheetah_escape(x) for x in scr]
+ scrpt = [' %s' % x for x in scrpt if x.strip() > ''] # indent
+ scrpt.insert(0,'------\n\nScript::\n')
if len(scrpt) > 300:
safertext = (
safertext
@@ -563,9 +586,8 @@
+ scrpt[-100:]
)
else:
- safertext = safertext + scrpt
- safertext.append("\n```")
- self.newtool.help = "\n".join([x for x in safertext])
+ safertext = safertext + "\n".join(scrpt)
+ self.newtool.help = safertext
else:
self.newtool.help = (
"Please ask the tool author (%s) for help \
@@ -593,7 +615,7 @@
self.newtool.inputs = self.tinputs
if self.args.script_path:
configfiles = gxtp.Configfiles()
- configfiles.append(gxtp.Configfile(name="runme", text=self.script))
+ configfiles.append(gxtp.Configfile(name="runme", text=self.escapedScript))
self.newtool.configfiles = configfiles
tests = gxtp.Tests()
test_a = gxtp.Test()
@@ -607,8 +629,7 @@
)
self.newtool.add_comment("Source in git at: %s" % (toolFactoryURL))
self.newtool.add_comment(
- "Cite: Creating re-usable tools from scripts doi: \
- 10.1093/bioinformatics/bts573"
+ "Cite: Creating re-usable tools from scripts doi:10.1093/bioinformatics/bts573"
)
exml0 = self.newtool.export()
exml = exml0.replace(FAKEEXE, "") # temporary work around until PR accepted
@@ -806,8 +827,6 @@
repos = ts.repositories.get_repositories()
rnames = [x.get("name", "?") for x in repos]
rids = [x.get("id", "?") for x in repos]
- sto.write(f"############names={rnames} rids={rids}\n")
- sto.write(f"############names={repos}\n")
tfcat = "ToolFactory generated tools"
if self.tool_name not in rnames:
tscat = ts.categories.get_categories()
@@ -827,7 +846,6 @@
category_ids=catID,
)
tid = res.get("id", None)
- sto.write(f"##########create res={res}\n")
else:
i = rnames.index(self.tool_name)
tid = rids[i]
diff -r 18e616939a91 -r e878bfc6b80c toolfactory/rgToolFactory2.xml
--- a/toolfactory/rgToolFactory2.xml Sat Nov 28 02:52:24 2020 +0000
+++ b/toolfactory/rgToolFactory2.xml Sun Nov 29 04:32:22 2020 +0000
@@ -79,7 +79,7 @@
+ help="Available options are diff:[lines], sim_size:[delta (integer) or delta_frac (float)" value="sim_size:0.01"/>
@@ -232,7 +232,7 @@
-
+
@@ -243,8 +243,8 @@
-
-
+
+
@@ -324,8 +324,8 @@
-
-
+
+