Package schrodinger :: Package utils :: Module sea :: Class Sea
[hide private]
[frames] | no frames]

Class Sea

object --+
         |
        Sea
Known Subclasses:


This is the base class the 'Atom', 'List', and 'Map' classes.
A 'Sea' object will manage three types of information:
   tag     As the name suggests, tags allow users of the 'Sea' object to
           label the object with strings and latter on to extract or print
           those with certain tags.
   parent  Pointer (weak reference) to the parent of this 'Sea' object.

Operations to manipulate these data are defined in this base class.

Instance Methods [hide private]
 
__init__(self, parent=None)
Creates and initializes a 'Sea' object.
 
__getstate__(self)
This is needed for pickling.
 
__setstate__(self, ark)
Restores the 'Sea' object from an object of the buildin type.
 
__deepcopy__(self, memo={})
 
__deepcopy__old(self, memo={})
Returns a deep copy of this 'Sea' object.
 
__str__(self)
Subclasses of the 'Sea' class must implement this function if conversion of the subclass's instances to strings is needed.
 
__ne__(self, rhs)
Returns True if the value of this object does not equal that of 'rhs'.
 
__eq__(self, rhs)
Returns True if the value of this object equals that of 'rhs'.
 
__get_sval(self)
Used by the 'sval' property, which is to get an 'Sea' object of the value that is represented by this 'Sea' object.
 
apply(self, op)
Recursively applies the operation as given by 'op' to all 'Sea' subobjects of this 'Sea' object.
 
parent(self)
Rerturns the parent of this 'Sea' object or None if it does not have a parent.
 
set_parent(self, parent)
Sets the parent of this 'Sea' object to the given 'parent'.
 
tag(self)
Returns tags, which are 'set' objects.
 
has_tag(self, tag)
Returns True if we already tagged this object with the given 'tag'.
 
_add_tag_impl(self, tag, propagate)
 
add_tag(self, tag, propagate=True)
Tags this object with another string(s).
 
_remove_tag_impl(self, tag, propagate)
 
remove_tag(self, tag, propagate=True)
Removes a tag.
 
_reset_tag_impl(self, tag, propagate)
 
reset_tag(self, tag, propagate=True)
Resets the tag of this object to the given 'tag'.
 
clear_all_tag(self, propagate=True)
Removes all tags.
 
pmode(self)
Returns the printing mode.
 
set_pmode(self, pmode, propagate=True)
Resets the printing mode of this object to the given 'pmode'.
 
_dump_impl(self, tag)
 
dump(self, tag=set([]))
Converts this 'Sea' object into a string that looks ugly (yet syntactically correct).

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __subclasshook__

Static Methods [hide private]
 
_normalize_tag(tag)
User can supply either a single string, or a list, or a set of strings as tags.
 
_gen_sea(ark, parent)
Creates a new 'Map' or 'List' or 'Atom' object from the given data 'ark' and sets the parent of this new object to the given 'parent', and then returns this new object.
Properties [hide private]
  sval
Readonly.

Inherited from object: __class__

Method Details [hide private]

_normalize_tag(tag)
Static Method

 

User can supply either a single string, or a list, or a set of strings as tags. This function will normalize the string or list types of tags to the set type. This function will return a set object.

_gen_sea(ark, parent)
Static Method

 

Creates a new 'Map' or 'List' or 'Atom' object from the given data 'ark' and sets the parent of this new object to the given 'parent', and then returns this new object.

Parameters:
  • ark - The data object for which to create a new 'Map' or 'List' or 'Atom' object for. The 'ark' must be of a buildin type. If it is a dict, a 'Map' object will be created and returned; if it is a list or tuple, a 'List' object will be created and returned; otherwise, an 'Atom' object will be created and returned.
  • parent - The parent of the new object. It can be None.

__init__(self, parent=None)
(Constructor)

 

Creates and initializes a 'Sea' object.

Parameters:
  • parent - This paremeter provides the parent of this 'Sea' object. It can be None.
Overrides: object.__init__

__getstate__(self)

 

This is needed for pickling. The returned object is of a buildin type (dict, list, int, str, float, ...).

__deepcopy__old(self, memo={})

 

Returns a deep copy of this 'Sea' object. The duplicate will be the same except its parent and its backup.

__str__(self)
(Informal representation operator)

 

Subclasses of the 'Sea' class must implement this function if conversion of the subclass's instances to strings is needed.

Overrides: object.__str__

__eq__(self, rhs)
(Equality operator)

 

Returns True if the value of this object equals that of 'rhs'. Subclasses of the 'Sea' class must implement this function.

__get_sval(self)

 

Used by the 'sval' property, which is to get an 'Sea' object of the value that is represented by this 'Sea' object. Normally this function just returns itself. But when this 'Sea' object is referring to another 'Sea' object, the latter should be returned -- this functionality is left to subclasses to implement if it makes sense for that subclass.

has_tag(self, tag)

 

Returns True if we already tagged this object with the given 'tag'.

Parameters:
  • tag - The given 'tag' can be a string, or a list of strings, or a 'set' of strings.

add_tag(self, tag, propagate=True)

 

Tags this object with another string(s).

Parameters:
  • tag - The given 'tag' can be a string, or a list of strings, or a 'set' of strings.
  • propagate - If True, the function will propagate the operation to all 'Sea' subobjects.

remove_tag(self, tag, propagate=True)

 

Removes a tag.

Parameters:
  • tag - The given 'tag' can be a string, or a list of strings, or a 'set' of strings.
  • propagate - If True, the function will propagate the operation to all 'Sea' subobjects.

reset_tag(self, tag, propagate=True)

 

Resets the tag of this object to the given 'tag'.

Parameters:
  • tag - The given 'tag' can be a string, or a list of strings, or a 'set' of strings.
  • propagate - If True, the function will propagate the operation to all 'Sea' subobjects.

clear_all_tag(self, propagate=True)

 

Removes all tags.

Parameters:
  • propagate - If True, the function will propagate the operation to all 'Sea' subobjects.

set_pmode(self, pmode, propagate=True)

 

Resets the printing mode of this object to the given 'pmode'.

Parameters:
  • propagate - If True, the function will propagate the operation to all 'Sea' subobjects.

dump(self, tag=set([]))

 

Converts this 'Sea' object into a string that looks ugly (yet syntactically correct). This method is 50%-900% faster than the __str__ method.


Property Details [hide private]

sval

Readonly. Returns the current `Sea' object.

Get Method:
__get_sval(self) - Used by the 'sval' property, which is to get an 'Sea' object of the value that is represented by this 'Sea' object.