pydi.srccat
index
/cygdrive/c/dev/workspace/pydi_open/src/pydi/srccat.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/>.
 
 
srccat.py - source catalog
 
Eithon Cadag
 
Example usage:
   
   import sexpparse
   reader = sexpparse.SexpSchemaSourceLinkReader('myschema.txt')
   srccat = SourceCatalog(reader.get_schema(),reader.get_sources(),reader.get_links())
   srccat.get_mappings_by_srcname_clsname("NCBI","Gene")

 
Modules
       
pydi.decorators
pydi.schema
warnings

 
Classes
       
exceptions.Exception(exceptions.BaseException)
InvalidLinkException
InvalidMappableException
InvalidMappingException
InvalidPropertyException
InvalidQueryException
InvalidSourcePropertyException
NoLinkException
NoSourceException
NoSourcedClassException
Source
SourceCatalog
SourceLink
SourceLinkHead
SourceLinkReader
SourceLinkTail
SourceMapping
SourceQueryable
SourceReader
SourcedCls
SrcClsInterface

 
class InvalidLinkException(exceptions.Exception)
    
Method resolution order:
InvalidLinkException
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 InvalidMappableException(exceptions.Exception)
    
Method resolution order:
InvalidMappableException
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 InvalidMappingException(exceptions.Exception)
    
Method resolution order:
InvalidMappingException
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 InvalidPropertyException(exceptions.Exception)
    
Method resolution order:
InvalidPropertyException
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 InvalidQueryException(exceptions.Exception)
    
Method resolution order:
InvalidQueryException
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 InvalidSourcePropertyException(exceptions.Exception)
    
Method resolution order:
InvalidSourcePropertyException
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 NoLinkException(exceptions.Exception)
    
Method resolution order:
NoLinkException
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 NoSourceException(exceptions.Exception)
    
Method resolution order:
NoSourceException
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 NoSourcedClassException(exceptions.Exception)
    
Method resolution order:
NoSourcedClassException
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 Source
     Methods defined here:
__init__(self, name, srcd_clses=None)
Sources need:
- Classes defined (generate SourcedCls)
- Per class, per source specific properties (e.g., foreign keys) (done per class)
- Knowledge of how it can be queried (consider defining the query within the
  source, then allow link-mappings to cite the query within the source as a way of 
  linking.
- Queries defined in the source need to know what parameters they may pass (handled in SourceQueryable)
- Each source should have mappings (src->schema) defined (done per class)
__repr__(self)
cls_by_name(self, str_clsname)
cls_to_query_hash(self)
get_classes(self)
These are SOURCED classes.
get_name(self)
query_by_cls(self, src_cls)

Data descriptors defined here:
classes
These are SOURCED classes.
name

 
class SourceCatalog
    TODO: This class needs cleaning up...
 
  Methods defined here:
__init__(self, schema, sources, links)
Source catalog needs:
- References to Source objs
- Access to Source queryables
- Knowledge of how the sources interconnect
- Schema
activate_source(self, src)
get_generator_by_link(self, linkname)
Note -- generators are not generators in the strict Python sense -- they are DataSetGenerators.
get_link_by_name(self, linkname)
get_links_by_clsname(self, str_cls)
Return the links that are pointed to by specific clsname.
get_links_by_srcname_clsname(self, str_src, str_cls)
Returns only links from active sources.
get_links_from_head_srcname_clsname(self, str_src, str_cls)
Return the sources that are pointed to from a specified source and class.
get_mappings_by_srcname_clsname(self, str_src, str_cls)
get_properties_by_srcname_clsname_propname(self, str_src, str_cls, str_prop)
get_queries_by_srcname_clsname(self, str_src, str_cls)
get_queries_by_srcname_clsname_queryname(self, str_src, str_cls, str_qry)
get_source_names(self)
get_src_by_srcname(self, str_src)
Return the source by source name
get_tail_clses_from_head_clsname(self, str_cls)
Return the classes that are pointed to from a given class(str), regardless of source.
get_tail_clses_from_head_srcname_clsname(self, str_src, str_cls)
Return the classes that are pointed to from a given source, regardless of class.
get_trigger_by_srcname_clsname(self, str_src, str_cls)
inactivate_source(self, src_str)
valid_clses_for_src_str(self, str_src)

Data descriptors defined here:
active_sources
links
schema
sources

 
class SourceLink
     Methods defined here:
__init__(self, name, head, tail, gen=None)
__repr__(self)
__str__(self)
get_generator_str(self)
get_head(self)
get_name(self)
get_tail(self)

Data descriptors defined here:
gen_str
head
name
tail

 
class SourceLinkHead
     Methods defined here:
__init__(self, src, src_cls, prp)
__repr__(self)
__str__(self)
get_property(self)
get_source(self)
get_sourced_cls(self)

Data descriptors defined here:
prop
source
sourced_cls

 
class SourceLinkReader
     Methods defined here:
serialize_links(self)

 
class SourceLinkTail
     Methods defined here:
__init__(self, src, src_cls, qry, mappings)
__repr__(self)
__str__(self)
get_mappings(self)
get_query(self)
get_source(self)
get_sourced_cls(self)
label2mapto(self, label)

Data descriptors defined here:
mappings
query
source
sourced_cls

 
class SourceMapping
     Methods defined here:
__init__(self, lbl, mapto)
lbl|->mapsto
__repr__(self)
__str__(self)
get_label(self)
get_mapsto(self)

Data descriptors defined here:
label
mapsto

 
class SourceQueryable
     Methods defined here:
__init__(self, name, prps=None, params=None)
__repr__(self)
__str__(self)
get_name(self)
get_param(self, p)
get_params(self)
get_properties(self)

Data descriptors defined here:
name
parameters
properties

 
class SourceReader
     Methods defined here:
serialize_sources(self)

 
class SourcedCls
    Essentially a decorator around ClsTemplate objs; adds property fields and storage for source-class-specific mappings.
 
  Methods defined here:
__init__(self, cls, trigger, mappings, queries, props=None)
get_all_attributes(self)
get_attr_prop(self, ap)
get_cls(self)
get_mappings(self)
get_properties(self)
get_queries(self)
get_query_by_name(self, qname)
get_trigger(self)
is_valid_attr_prop(self, ap)
label2mapto(self, label)

Data descriptors defined here:
attributes
cls
mappings
properties
queries
trigger

 
class SrcClsInterface
     Methods defined here:
cls_name(self)
get_value(self, lbl)
set_value(self, lvl, val)
source_name(self)