Skip to content

Instantly share code, notes, and snippets.

@hexylena
Last active May 16, 2019 13:39
Show Gist options
  • Save hexylena/dd4e971f4b94f171c75836a6a594743c to your computer and use it in GitHub Desktop.
Save hexylena/dd4e971f4b94f171c75836a6a594743c to your computer and use it in GitHub Desktop.
Galaxy tool to dump available attributes
<tool id="debugger" name="Debug available vars" version="0.0.1">
<macros>
<token name="@DUMMPER@">
<![CDATA[
<html><body>
<h1>$myobjname</h1>
<div style="display: flex">
<div style="width: 300px; min-width: 300px; height: 900px; overflow-y: scroll; overflow-x: hidden;">
<ul>
#if hasattr(myobj, 'to_dict'):
<li><a href="#to_dict">to_dict</a></li>
#else if hasattr(myobj, 'to_dataset_instances'):
<li><a href="#to_dataset_instances">to_dataset_instances</a></li>
#end if
#for x in sorted(dir(myobj)):
#if not x.startswith("__"):
<li><a href="#$x">$x</a></li>
#end if
#end for
</ul>
</div>
<div style="height: 900px; overflow-y: scroll">
#if hasattr(myobj, 'to_dict'):
<h2 id="to_dict"><span style="color:gray">$myobjname.</span>to_dict</h2>
<pre>
#for k, v in sorted(myobj.to_dict().items()):
${str(k)} = ${str(v).replace('__lt__', '&lt;').replace('__gt__', '&gt;').replace('__sq__', "'").replace('__dq__', '"').replace('__ob__', '[').replace('__cb__', ']').replace('__oc__', '{').replace('__cc__', '}').replace('__at__', '@').replace('__cn__', '\n').replace('__cr__', '\r').replace('__tc__', '\t').replace('__pd__', '#')}
#end for
</pre>
#end if
#for x in sorted(dir(myobj)):
#if not x.startswith("__"):
<h2 id="$x"><span style="color:gray">$myobjname.</span>$x
#try:
#set q = type(getattr(myobj, x)).__name__
<span style="color: gray">
#if '(' in str(q):
(${type(getattr(myobj, x)).__module__}.${q[0:q.index('(')]})
#else
(${type(getattr($myobj, x)).__module__}.${q})
#end if
</span>
#except
&nbsp;
#end try
</h2>
#try:
#set b = getattr(myobj, x)
#if type(b) in (str, bool, int, float, None):
<pre>${b}</pre>
#else if 'galaxy.util.object_wrapper.SafeStringWrapper' in str(type(b).__name__):
<pre>
${str(b).replace('__lt__', '&lt;').replace('__gt__', '&gt;').replace('__sq__', "'").replace('__dq__', '"').replace('__ob__', '[').replace('__cb__', ']').replace('__oc__', '{').replace('__cc__', '}').replace('__at__', '@').replace('__cn__', '\n').replace('__cr__', '\r').replace('__tc__', '\t').replace('__pd__', '#')}
</pre>
#else if type(b) == list:
#for e in b:
<code>
#if type(e) in (str, bool, int, float, None):
${e}
#else if 'galaxy.util.object_wrapper.SafeStringWrapper' in str(type(e).__name__):
${str(e).replace('__lt__', '&lt;').replace('__gt__', '&gt;').replace('__sq__', "'").replace('__dq__', '"').replace('__ob__', '[').replace('__cb__', ']').replace('__oc__', '{').replace('__cc__', '}').replace('__at__', '@').replace('__cn__', '\n').replace('__cr__', '\r').replace('__tc__', '\t').replace('__pd__', '#')}
#end if
</code>
<br/>
#end for
#else if type(b) == dict:
#for k, v in b.items():
<code>
#if type(v) in (str, bool, int, float, None):
${k} = ${v}
#else if 'galaxy.util.object_wrapper.SafeStringWrapper' in str(type(v).__name__):
${k} = ${str(v).replace('__lt__', '&lt;').replace('__gt__', '&gt;').replace('__sq__', "'").replace('__dq__', '"').replace('__ob__', '[').replace('__cb__', ']').replace('__oc__', '{').replace('__cc__', '}').replace('__at__', '@').replace('__cn__', '\n').replace('__cr__', '\r').replace('__tc__', '\t').replace('__pd__', '#')}</pre>
#end if
</code>
<br />
#end for
#else if x == "to_dict":
#for k, v in sorted(myobj.to_dict().items()):
<code>
#if type(v) in (str, bool, int, float, None):
${k} = ${v}
#else if 'galaxy.util.object_wrapper.SafeStringWrapper' in str(type(v).__name__):
${k} = ${str(v).replace('__lt__', '&lt;').replace('__gt__', '&gt;').replace('__sq__', "'").replace('__dq__', '"').replace('__ob__', '[').replace('__cb__', ']').replace('__oc__', '{').replace('__cc__', '}').replace('__at__', '@').replace('__cn__', '\n').replace('__cr__', '\r').replace('__tc__', '\t').replace('__pd__', '#')}</pre>
#end if
</code>
<br />
#end for
#else:
#for z in dir(b):
#if not z.startswith('__'):
<code>$z
#if type(z) in (str, bool, int, float, None):
= ${str(getattr(b, z)).replace('>', '&gt;').replace('<', '&lt;')}
#else#&nbsp;#end if#
</code>
<br/>
#end if
#end for
#end if
#except
-
#end try
#end if
#end for
</div>
</div>
</body></html>
]]>
</token>
</macros>
<configfiles>
<configfile name="user"><![CDATA[
#set myobj = $__user__.obj
#set myobjname = '$__user__'
@DUMMPER@
]]>
</configfile>
<configfile name="app"><![CDATA[
#set myobj = $__app__.obj
#set myobjname = '$__app__'
@DUMMPER@
]]>
</configfile>
<configfile name="iput"><![CDATA[
#set myobj = $input
#set myobjname = '$input'
@DUMMPER@
]]>
</configfile>
<configfile name="iputm"><![CDATA[
#set myobj = $input_multiple
#set myobjname = '$input_multiple'
@DUMMPER@
]]>
</configfile>
</configfiles>
<command detect_errors="exit_code">
mv $app $out_a;
mv $user $out_u;
#if $input:
mv $iput $out_f;
#end if
#if $input_multiple:
mv $iputm $out_m;
#end if
</command>
<inputs>
<param name="input" type="data" optional="True"/>
<param name="input_multiple" type="data" optional="True" multiple="True"/>
</inputs>
<outputs>
<data format="html" name="out_a" label="App"/>
<data format="html" name="out_u" label="User"/>
<data format="html" name="out_f" label="Input">
<filter>input</filter>
</data>
<data format="html" name="out_m" label="Input Multiple">
<filter>input_multiple</filter>
</data>
</outputs>
</tool>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment