pydi.schema
index
/cygdrive/c/dev/workspace/pydi_open/src/pydi/schema.py

Copyright (C) 2008 Eithon Cadag
 
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
 
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
 
You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 
 
schema.py - frame-based schema representation
 
Eithon Cadag
 
Example usage:

 
Classes
       
exceptions.Exception(exceptions.BaseException)
DuplicateClsException
NoAttributeException
NoClsException
ClsTemplate
Schema
SchemaReader

 
class ClsTemplate
    Seperate from a class instance; has attribute information, but not SOURCE information.
Mapper should use this class to translate Tuple data into actual instances.
Note that the setting of parents/children involve calling the parameter parent/child's
own set child/parent method; setting the parent/child for a ClsTemplate should automatically
set the corresponding child/parent for the other ClsTemplate involved.
 
  Methods defined here:
__init__(self, name, par=None, att=None)
__repr__(self)
add_child(self, c_template)
add_parent(self, p_template)
cls_name(self)
get_all_attributes(self)
get_attribute(self, attr)
get_attributes_list(self)
get_children(self)
get_local_attribute(self, attr)
get_parents(self)
has_attribute(self, attr)
has_child(self, c)
has_parent(self, p)
list_all_attributes(self)
list_local_attributes(self)
remove_child(self, c)
remove_parent(self, p)
set_attribute(self, attr, arity=0)

Data descriptors defined here:
attributes
name

Data and other attributes defined here:
MULTIPLE = 1
SINGULAR = 0

 
class DuplicateClsException(exceptions.Exception)
    
Method resolution order:
DuplicateClsException
exceptions.Exception
exceptions.BaseException
__builtin__.object

Methods defined here:
__init__(self, msg)

Data descriptors defined here:
__weakref__
list of weak references to the object (if defined)

Data and other attributes inherited from exceptions.Exception:
__new__ = <built-in method __new__ of type object at 0x6cb87ab0>
T.__new__(S, ...) -> a new object with type S, a subtype of T

Methods inherited from exceptions.BaseException:
__delattr__(...)
x.__delattr__('name') <==> del x.name
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__getitem__(...)
x.__getitem__(y) <==> x[y]
__getslice__(...)
x.__getslice__(i, j) <==> x[i:j]
 
Use of negative indices is not supported.
__reduce__(...)
__repr__(...)
x.__repr__() <==> repr(x)
__setattr__(...)
x.__setattr__('name', value) <==> x.name = value
__setstate__(...)
__str__(...)
x.__str__() <==> str(x)

Data descriptors inherited from exceptions.BaseException:
__dict__
args
message
exception message

 
class NoAttributeException(exceptions.Exception)
    
Method resolution order:
NoAttributeException
exceptions.Exception
exceptions.BaseException
__builtin__.object

Methods defined here:
__init__(self, msg)

Data descriptors defined here:
__weakref__
list of weak references to the object (if defined)

Data and other attributes inherited from exceptions.Exception:
__new__ = <built-in method __new__ of type object at 0x6cb87ab0>
T.__new__(S, ...) -> a new object with type S, a subtype of T

Methods inherited from exceptions.BaseException:
__delattr__(...)
x.__delattr__('name') <==> del x.name
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__getitem__(...)
x.__getitem__(y) <==> x[y]
__getslice__(...)
x.__getslice__(i, j) <==> x[i:j]
 
Use of negative indices is not supported.
__reduce__(...)
__repr__(...)
x.__repr__() <==> repr(x)
__setattr__(...)
x.__setattr__('name', value) <==> x.name = value
__setstate__(...)
__str__(...)
x.__str__() <==> str(x)

Data descriptors inherited from exceptions.BaseException:
__dict__
args
message
exception message

 
class NoClsException(exceptions.Exception)
    
Method resolution order:
NoClsException
exceptions.Exception
exceptions.BaseException
__builtin__.object

Methods defined here:
__init__(self, msg)

Data descriptors defined here:
__weakref__
list of weak references to the object (if defined)

Data and other attributes inherited from exceptions.Exception:
__new__ = <built-in method __new__ of type object at 0x6cb87ab0>
T.__new__(S, ...) -> a new object with type S, a subtype of T

Methods inherited from exceptions.BaseException:
__delattr__(...)
x.__delattr__('name') <==> del x.name
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__getitem__(...)
x.__getitem__(y) <==> x[y]
__getslice__(...)
x.__getslice__(i, j) <==> x[i:j]
 
Use of negative indices is not supported.
__reduce__(...)
__repr__(...)
x.__repr__() <==> repr(x)
__setattr__(...)
x.__setattr__('name', value) <==> x.name = value
__setstate__(...)
__str__(...)
x.__str__() <==> str(x)

Data descriptors inherited from exceptions.BaseException:
__dict__
args
message
exception message

 
class Schema
    Class that contains the instances of ClsTemplate. This class is sort of
like a big, wrapping memoization, with a root cls.
 
  Methods defined here:
__init__(self)
add_cls(self, cls, overwrite=False)
Adds a ClsTemplate to schema as a child of root.
cls_has_child_cls_str(self, p_cls_str, c_cls_str)
Returns True if p_cls is a parent of c_cls; False otherwise.
get_all_clses(self)
Returns a breadth-first ordering of all clses in Schema.
get_cls(self, cls_name)
Parameter is a string.
has_cls(self, cls)
has_cls_by_name(self, cls_str)
reindex(self)
root(self)

Data and other attributes defined here:
ID = '#ID'
ROOT_STR = 'ROOT'
SOURCE = '#SOURCE'

 
class SchemaReader
    Generic class that translates some data representation into a Schema.
 
  Methods defined here:
__init__(self)
serialize_schema(self)