view couchdb_client.xml @ 2:1fce03693725 draft

Uploaded
author kellrott
date Tue, 24 Jul 2012 17:41:32 -0400
parents 907b95ba9cf7
children
line wrap: on
line source

<tool id="couchdb_client" name="CouchDB Client" version="1.0.0">
  <description>CouchDB Client</description>
  <command interpreter="python">$scriptfile</command>
  <inputs>
	  <param name="url" type="text" size="128" label="Server URL"/>
	  <param name="db" type="text" size="32" label="Database"/>
	  <param name="query" type="text" area="True" size="5x25" label="Query">
		<sanitizer>
			<valid initial="string.printable"/>
			<mapping initial="none">
				<add source="&#10;" target="__cn__"/>
				<add source="&quot;" target="__dq__"/>
			</mapping>
		</sanitizer>
	  </param>      
  </inputs>
  <outputs>
      <data name="output" format="txt"/>
  </outputs>
  	<configfiles>

  <configfile name="scriptfile"><![CDATA[#!/usr/bin/env python
import couchdb.client
import json
import galaxy.eggs
import galaxy.util

server = couchdb.client.Server(galaxy.util.restore_text("$url"))
db = server['$db']

query=galaxy.util.restore_text("""$query""")
print query
result = db.query(query)
print result
handle = open(galaxy.util.restore_text("$output"), "w")
for row in result:
	handle.write("{\"key\":%s, \"value\":%s}\n" % (json.dumps(row.key), json.dumps(row.value)))
handle.close()

]]></configfile>
  	</configfiles>
<help>


</help>
</tool>