[hg] galaxy 1526: Convert metadata unicode strings to ascii ( pr...

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[hg] galaxy 1526: Convert metadata unicode strings to ascii ( pr...

greg
details:   http://www.bx.psu.edu/hg/galaxy/rev/38e533287df4
changeset: 1526:38e533287df4
user:      Greg Von Kuster <[hidden email]>
date:      Wed Sep 24 11:14:44 2008 -0400
description:
Convert metadata unicode strings to ascii ( previous code doesn't seem to do anything, am I missing something? ).  Add no_value metadata attribute to columns and column_types metadata.  Fix for column_maker and filter tools.

4 file(s) affected in this change:

lib/galaxy/datatypes/metadata.py
lib/galaxy/datatypes/tabular.py
tools/stats/column_maker.py
tools/stats/filtering.py

diffs (79 lines):

diff -r 675ad84ae008 -r 38e533287df4 lib/galaxy/datatypes/metadata.py
--- a/lib/galaxy/datatypes/metadata.py Mon Sep 22 12:02:35 2008 -0400
+++ b/lib/galaxy/datatypes/metadata.py Wed Sep 24 11:14:44 2008 -0400
@@ -60,10 +60,10 @@
         if isinstance( value, ListType ):
             for i, elem in enumerate( value ):
                 if type ( elem ) == unicode:
-                    value[i] = str( elem )
+                    value[i] = elem.decode( 'ascii' )
         elif isinstance ( value, basestring ):
             if type( value ) == unicode:
-                value = str( value )
+                value = value.decode( 'ascii' )
         self.value = value
         self.context = context
         self.display = True
@@ -76,7 +76,7 @@
     @classmethod
     def marshal( cls, value ):
         '''
-        This method should/can be overridden to convert the incomming
+        This method should/can be overridden to convert the incoming
         value to whatever type it is supposed to be.
         '''
         return value
@@ -273,7 +273,6 @@
 class ColumnTypesParameter( MetadataParameter ):
     def __init__( self, spec, value, context ):
         MetadataParameter.__init__( self, spec, value, context )
-
     def __str__(self):
         return ",".join( map( str, self.value ) )
 
diff -r 675ad84ae008 -r 38e533287df4 lib/galaxy/datatypes/tabular.py
--- a/lib/galaxy/datatypes/tabular.py Mon Sep 22 12:02:35 2008 -0400
+++ b/lib/galaxy/datatypes/tabular.py Wed Sep 24 11:14:44 2008 -0400
@@ -19,8 +19,8 @@
     """Tab delimited data"""
 
     """Add metadata elements"""
-    MetadataElement( name="columns", default=0, desc="Number of columns", readonly=True, visible=False )
-    MetadataElement( name="column_types", default=[], desc="Column types", param=metadata.ColumnTypesParameter, readonly=True, visible=False )
+    MetadataElement( name="columns", default=0, desc="Number of columns", readonly=True, visible=False, no_value=0 )
+    MetadataElement( name="column_types", default=[], desc="Column types", param=metadata.ColumnTypesParameter, readonly=True, visible=False, no_value=[] )
 
     def init_meta( self, dataset, copy_from=None ):
         data.Text.init_meta( self, dataset, copy_from=copy_from )
diff -r 675ad84ae008 -r 38e533287df4 tools/stats/column_maker.py
--- a/tools/stats/column_maker.py Mon Sep 22 12:02:35 2008 -0400
+++ b/tools/stats/column_maker.py Wed Sep 24 11:14:44 2008 -0400
@@ -19,12 +19,10 @@
 round = sys.argv[4]
 try:
     in_columns = int( sys.argv[5] )
-    # in_column_types is passed as a string that looks something like:
-    # "[u'str', u'int', u'int', u'str', u'int', u'str']"
-    in_column_types = sys.argv[6].strip( '[' ).strip( ']' ).replace( 'u', '' ).replace( "'", '' ).split( ',' )
+    in_column_types = sys.argv[6].split( ',' )
 except:
     stop_err( "Data does not appear to be tabular.  This tool can only be used with tab-delimited data." )
-
+    
 # Unescape if input has been escaped
 mapped_str = {
     '__lt__': '<',
diff -r 675ad84ae008 -r 38e533287df4 tools/stats/filtering.py
--- a/tools/stats/filtering.py Mon Sep 22 12:02:35 2008 -0400
+++ b/tools/stats/filtering.py Wed Sep 24 11:14:44 2008 -0400
@@ -26,9 +26,7 @@
 cond_text = sys.argv[3]
 try:
     in_columns = int( sys.argv[4] )
-    # in_column_types is passed as a string that looks something like:
-    # "[u'str', u'int', u'int', u'str', u'int', u'str']"
-    in_column_types = sys.argv[5].strip( '[' ).strip( ']' ).replace( 'u', '' ).replace( "'", '' ).split( ',' )
+    in_column_types = sys.argv[5].split( ',' )
 except:
     stop_err( "Data does not appear to be tabular.  This tool can only be used with tab-delimited data." )