<s> class Blob ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , value = None , file = None , id = None ) : <EOL> self . _file = file <EOL> self . id = id <EOL> self . value = value <EOL> @ property <EOL> def file ( self ) : <EOL> from StringIO import StringIO <EOL> if self . _file : <EOL> f = self . _file <EOL> else : <EOL> f = StringIO ( self . value ) <EOL> return f <EOL> def __str__ ( self ) : <EOL> return unicode ( self ) . encode ( '<STR_LIT:utf-8>' ) <EOL> def __unicode__ ( self ) : <EOL> if hasattr ( self . file , "<STR_LIT>" ) : <EOL> value = self . file . get_contents_as_string ( ) <EOL> else : <EOL> value = self . file . getvalue ( ) <EOL> if isinstance ( value , unicode ) : <EOL> return value <EOL> else : <EOL> return value . decode ( '<STR_LIT:utf-8>' ) <EOL> def read ( self ) : <EOL> if hasattr ( self . file , "<STR_LIT>" ) : <EOL> return self . file . get_contents_as_string ( ) <EOL> else : <EOL> return self . file . read ( ) <EOL> def readline ( self ) : <EOL> return self . file . readline ( ) <EOL> def next ( self ) : <EOL> return self . file . next ( ) <EOL> def __iter__ ( self ) : <EOL> return iter ( self . file ) <EOL> @ property <EOL> def size ( self ) : <EOL> if self . _file : <EOL> return self . _file . size <EOL> elif self . value : <EOL> return len ( self . value ) <EOL> else : <EOL> return <NUM_LIT:0> </s>
