Package mvpa :: Package misc :: Package io :: Module hamster :: Class Hamster
[hide private]
[frames] | no frames]

Class Hamster

source code


Simple container class with basic IO capabilities.

It is capable of storing itself in a file, or loading from a file using cPickle (optionally via zlib from compressed files). Any serializable object can be bound to a hamster to be stored.

To undig burried hamster use Hamster(filename). Here is an example:

>>> h = Hamster(bla='blai')
>>> h.boo = N.arange(5)
>>> h.dump(filename)
...
>>> h = Hamster(filename)

Since Hamster introduces methods dump, asdict and property 'registered', those names cannot be used to assign an attribute, nor provided in among constructor arguments.

Instance Methods [hide private]
a new object with type S, a subtype of T
__new__(cls, *args, **kwargs) source code
 
__init__(self, *args, **kwargs)
Initialize Hamster.
source code
 
dump(self, filename, compresslevel='auto')
Bury the hamster into the file
source code
 
__repr__(self)
repr(x)
source code
 
registered(self)
List registered attributes.
source code
 
__setattr__(self, k, v)
Just to prevent resetting read-only attributes, such as methods
source code
 
asdict(self)
Return registered data as dictionary
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __reduce__, __reduce_ex__, __sizeof__, __str__, __subclasshook__

Class Variables [hide private]
  __ro_attr = set(object.__dict__.keys()+ ['dump', 'registered',...
Attributes which come with being an object
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__new__(cls, *args, **kwargs)

source code 
Returns: a new object with type S, a subtype of T
Overrides: object.__new__
(inherited documentation)

__init__(self, *args, **kwargs)
(Constructor)

source code 

Initialize Hamster.

Providing a single parameter string would treat it as a filename from which to undig the data. Otherwise all keyword parameters are assigned into the attributes of the object.

Overrides: object.__init__

__repr__(self)
(Representation operator)

source code 
repr(x)
Overrides: object.__repr__
(inherited documentation)

registered(self)

source code 
List registered attributes.
Decorators:
  • @property

__setattr__(self, k, v)

source code 
Just to prevent resetting read-only attributes, such as methods
Overrides: object.__setattr__

Class Variable Details [hide private]

__ro_attr

Attributes which come with being an object
Value:
set(object.__dict__.keys()+ ['dump', 'registered', 'asdict'])