diff couchdb_client.xml @ 0:907b95ba9cf7 draft

Uploaded
author kellrott
date Tue, 24 Jul 2012 17:40:26 -0400
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/couchdb_client.xml	Tue Jul 24 17:40:26 2012 -0400
@@ -0,0 +1,46 @@
+<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>