PageRenderTime 14ms CodeModel.GetById 1ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 0ms

/lib/galaxy/util/none_like.py

https://bitbucket.org/cistrome/cistrome-harvard/
Python | 33 lines | 27 code | 2 blank | 4 comment | 1 complexity | a5576b46be8cdf652ee8a63c8b5b3fea MD5 | raw file
 1"""
 2Objects with No values
 3"""
 4from galaxy.datatypes.metadata import MetadataCollection
 5from galaxy.datatypes.registry import Registry
 6
 7class RecursiveNone:
 8    def __str__( self ):
 9        return "None"
10    def __repr__( self ):
11        return str( self )
12    def __getattr__( self, name ):
13        value = RecursiveNone()
14        setattr( self, name, value )
15        return value
16    def __nonzero__( self ):
17        return False
18
19class NoneDataset( RecursiveNone ):
20    def __init__( self, datatypes_registry = None, ext = 'data', dbkey = '?' ):
21        self.ext = self.extension = ext
22        self.dbkey = dbkey
23        if datatypes_registry is None:
24            # Default Value Required for unit tests
25            datatypes_registry = Registry()
26            datatypes_registry.load_datatypes()
27        self.datatype = datatypes_registry.get_datatype_by_extension( ext )
28        self._metadata = None
29        self.metadata = MetadataCollection( self )
30    def __getattr__( self, name ):
31        return "None"
32    def missing_meta( self ):
33        return False