pydi.datadir
index
/cygdrive/c/dev/workspace/pydi_open/src/pydi/datadir.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/>.
 
 
datadir.py -- Data directory
 
Eithon Cadag

 
Modules
       
pydi.callback
pydi.const
inspect
pydi.srccat
threading
types
warnings

 
Classes
       
exceptions.Exception(exceptions.BaseException)
InvalidArgumentLabelException
pydi.callback.UpdateCallBackRegister
ClsDatabase
ConcreteLinkDatabase
ClsRecordLoadedMonitor
ConcreteLink
ConcreteLinkLoadedMonitor
DataDirectory
DataSet
KeyedDataSet
DataSetGenerator
LinkInstance
pydi.srccat.SrcClsInterface
SourcedClsInstance

 
class ClsDatabase(pydi.callback.UpdateCallBackRegister)
    Directory of ClsInstance objs (mapped from a DataSet)
Note:
- Watch memory usage; before restarting a new (blank) query in the same session,
may need to use 'del' to remove references to database to clear memory.
 
  Methods defined here:
__init__(self, name, gen_start=0, ref_hash=None, recs=None, last_added=None)
add_cls_record = lockfnc(*args, **kwargs)
contains_instance_by_instance = lockfnc(*args, **kwargs)
contains_instance_by_sid(self, sid)
get_all_records(self)
get_name(self)
get_record(self, sid)
get_serializable(self)
register = lockfnc(*args, **kwargs)

Static methods defined here:
load_from_serializable(s)

Data descriptors defined here:
name
records

Data and other attributes defined here:
EMPTY_MULTIPLE = []
EMPTY_SINGLE = None
dbLock = <thread.lock object at 0x7ff12110>
obsLock = <thread.lock object at 0x7ff12120>

Data and other attributes inherited from pydi.callback.UpdateCallBackRegister:
processorLock = <thread.lock object at 0x7ff120e0>

 
class ClsRecordLoadedMonitor
    Abstract class for ClsDatabase observers to extend if they want to know when a new record has been loaded into the database.
 
  Methods defined here:
loaded_instance(self, ref, scls, db)

 
class ConcreteLink
    Class that represents a completely-loaded (i.e., both head and tail are loaded and instantiated) link between two instances.
 
  Methods defined here:
__init__(self, name, head_ci, tail_ci, edge_props)
__repr__(self)
__str__(self)
get_head(self)
get_name(self)
get_properties(self)
get_tail(self)
get_value(self, label)

Data descriptors defined here:
head
name
properties
tail

 
class ConcreteLinkDatabase(pydi.callback.UpdateCallBackRegister)
    Database to handle links that have already been posed, and are thus concretely connected to actual SourcedClsInstances.
 
  Methods defined here:
__init__(self, name, conn=None, rh=None)
add_record = lockfnc(*args, **kwargs)
get_all_records(self)
get_name(self)
get_record(self, head_id, head_src)
get_serializable(self)
register = lockfnc(*args, **kwargs)

Static methods defined here:
load_from_serializable(s)

Data descriptors defined here:
name
records

Data and other attributes defined here:
cdbLock = <thread.lock object at 0x7ff120f0>
obsLock = <thread.lock object at 0x7ff12100>

Data and other attributes inherited from pydi.callback.UpdateCallBackRegister:
processorLock = <thread.lock object at 0x7ff120e0>

 
class ConcreteLinkLoadedMonitor
    Abstract class for ConcreteLinkDatabase observers to extend if they want to know when a new record has been loaded into the database.
 
  Methods defined here:
loaded_link(self, ref, clink, db)

 
class DataDirectory
    TODO: Figure out why some things are left on the poslink_queue, and do not expand (it
looks like they are materialized indirectly, but they are not getting removed)...
 
  Methods defined here:
__init__(self, src_cat, dbs=None, cdbs=None, plink_queue=None)
add_instance_direct(self, src_name, cls_name, props)
add_instance_monitor(self, imon)
add_link_monitor(self, lmon)
delete_traversable = lockfnc(*args, **kwargs)
get_cdbs(self)
get_cls_instance(self, src_str, id_str)
get_dbs(self)
get_generator_for_link_name(self, lnk_str)
get_serializable(self)
get_total_cls_inst_count(self)
get_total_concrete_link_count(self)
get_traversable_links(self)
get_visited_links(self)
load_dataset = lockfnc(*args, **kwargs)
request_traversable_link = lockfnc(*args, **kwargs)
traversable_iterator = lockfnc(*args, **kwargs)
traversable_link_iterator(self)
Returns an iterator for the possible link list.

Static methods defined here:
load_from_serializable(s)

Data and other attributes defined here:
linkLock = <thread.lock object at 0x7ff120c0>
loadLock = <thread.lock object at 0x7ff120a0>

 
class DataSet
    Class that represents raw data returned from a source; think of a record or set tuple sets in a database...
 
  Methods defined here:
__init__(self, gen_name, src_name=None)
add_record(self, record_dict)
batch_properties(self, properties)
Adds to/replaces all records the k/v pairs in properties.
deepcopy(self)
Makes a deep copy of the dataset
get_generator_name(self)
get_query_term(self)
get_records(self)
get_source_name(self)
iterator(self)
query_term(self, query)
set_source_name(self, src_name)

Data descriptors defined here:
generator_name
query
rows
source_name

 
class DataSetGenerator
    Wrapper classes should inherit this class, and format data as a dictionary record '{<name>:<value>,...,<name>:<value>}'
 
  Methods defined here:
__init__(self, name, orig, query, params=None)
execute_query(self)
get_dataset(self)
Note: The originating source/id should be appended to each record before being returned!
get_request_originator(self)
is_loaded(self)
Return True if DataSet is completely loaded; False otherwise.
set_request_originator(self, orig)
Sets the originator of the request (used to mark who the 'head' is in a link relationship).

 
class InvalidArgumentLabelException(exceptions.Exception)
    
Method resolution order:
InvalidArgumentLabelException
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 KeyedDataSet(DataSet)
     Methods defined here:
__init__(self, src_name, args_default_dict, keys, name)
query_records(self, search_dict)

Methods inherited from DataSet:
add_record(self, record_dict)
batch_properties(self, properties)
Adds to/replaces all records the k/v pairs in properties.
deepcopy(self)
Makes a deep copy of the dataset
get_generator_name(self)
get_query_term(self)
get_records(self)
get_source_name(self)
iterator(self)
query_term(self, query)
set_source_name(self, src_name)

Data descriptors inherited from DataSet:
generator_name
query
rows
source_name

 
class LinkInstance
     Methods defined here:
__init__(self, head_ref, tail_ref, src_link)
__repr__(self)
__str__(self)
get_head_cls_str(self)
get_head_reference(self)
get_head_source_str(self)
get_link_parameters(self)
get_link_type(self)
get_name(self)
get_tail_cls_str(self)
get_tail_reference(self)
get_tail_source_str(self)
has_head_str(self, hsrc, href)
has_head_tail_str(self, hsrc, href, tsrc, tref)
has_tail_str(self, tsrc, tref)

Data descriptors defined here:
head_cls
head_reference
head_source
name
parameters
tail_cls
tail_reference
tail_source

 
class SourcedClsInstance(pydi.srccat.SrcClsInterface)
     Methods defined here:
__init__(self, record, srced_cls, unmapped=True)
Where record is a record in a DataSet (a dictionary of mappings),
the srced_cls is the sourced_cls instance, and query is the query that
spawned the sourced_cls.
__repr__(self)
__str__(self)
cls_name(self)
get_attr_props(self)
get_value(self, pattr)
set_value(self, pattr, value)
source_name(self)

Data descriptors defined here:
properties

 
Functions
       
make_id_generator(start_at=0)