pydi.bowser
index
/cygdrive/c/dev/workspace/pydi_open/src/pydi/bowser.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/>.
 
 
bowser.py - integration engine browser
 
Eithon Cadag
 
Example usage:
   
    import sexpparse,srccat
    
    reader = sexpparse.SexpSchemaSourceLinkReader('toy_schema7.txt')
    schema_ = reader.get_schema()
    sources_ = reader.get_sources()
    links_ = reader.get_links()
    catalog = srccat.SourceCatalog(schema_,sources_,links_)
 
    b = Bowser(catalog)
    b.seed("Seed","ProteinSequenceQuery","#ID","MAEDAHGFLELRGVTKRYGALAAVDGVDFTVDRGEVIGIGGPNGAGKTTFFDLISGLTRTTEGTIRFRDQDITGLAPHRLCRLGMARTFQLNSGFDNMTVFENLLAARAFGRRSAGGWLLTARADKQATQVLLDEIGLADIASDPVAGIPILARKKLMIATALIGEPDILLLDEPVGGLTPPEIDELIDLMLGLKSRGMTLVFIEHVMRFLTAVADRAVMMHQGRIIYDGTPGGLANDKTVAEVYLGSAGLGGMA")

 
Modules
       
cPickle
pydi.const
pydi.datadir
inspect
pydi.reqspool
pydi.sexpparse
pydi.srccat
threading
time
types
warnings

 
Classes
       
exceptions.Exception(exceptions.BaseException)
InvalidExpandableError
NoHitException
SpoolingRequestError
BowserSessionStore
Browser
Bowser(Browser, pydi.reqspool.RequestProcessor, pydi.datadir.ClsRecordLoadedMonitor, pydi.datadir.ConcreteLinkLoadedMonitor)
BrowserCacheInterface
TimedLock
pydi.reqspool.RequestExecutor
DataSetGeneratorExecutor

 
class Bowser(Browser, pydi.reqspool.RequestProcessor, pydi.datadir.ClsRecordLoadedMonitor, pydi.datadir.ConcreteLinkLoadedMonitor)
    Bowser browsing engine. This implementation of the Browser interface relies
on a relational-DB like interaction (i.e., straight-up referencing of the DataDirectory,
which stores data as if they were tabled records in a DB).
 
 
Method resolution order:
Bowser
Browser
pydi.reqspool.RequestProcessor
pydi.callback.UpdateObserver
pydi.datadir.ClsRecordLoadedMonitor
pydi.datadir.ConcreteLinkLoadedMonitor

Methods defined here:
__init__(self, cat, seeds=None, states=None, loaded=None, pending=None, dd=None, mem_cfg=None, p_cache=None)
add_dataset_load_listener(self, ds_listener)
Browser will pass a complete dataset when it appears.
add_instance_listener(self, inst_listener)
Browser will pass an instance listener the instance when it appears.
add_link_listener(self, lnk_listener)
Browser will pass a link listener the link instance when it appears.
add_query_listener(self, q_listener)
Browser will pass a query when it appears.
contains_record(self, src_str, ref_str)
end_session = lockfnc(*args, **kwargs)
entity_status(self)
expand(self, hsrc_str, hid_str)
Expand the entity with specified source and ID; ignores source state.
expand_all(self)
Expands all queries -- does not expand inactive sources.
get_all_instances(self)
get_all_instances_of_type_str(self, cls_type_str)
get_all_links(self)
get_data_directory(self)
Returns the data directory, which stores all the retrieved data in a series of databases.
get_instance_source_id(self, src_name, id_name)
get_record(self, src_str, id_str)
get_seeds(self)
Returns the seeds (user-specified queries).
is_busy = lockfnc(*args, **kwargs)
list_expandables(self)
List links that have yet to be expanded.
load_datasets(self, fname)
loaded_instance(self, ref, scls, db)
Callback to when an entity instance is loaded (scls is a SourcedClassInstance
loaded_link(self, ref, clink, db)
Callback to when a link is loaded.
pause = lockfnc(*args, **kwargs)
queries_suppressed(self)
request_status = lockfnc(*args, **kwargs)
resume = lockfnc(*args, **kwargs)
save_datasets(self, fname)
save_session(self, name)
Saves a session.
seed(self, source_str, cls_str, prop_str, value)
Seed a query to the specified source, class and property.
set_persistent_cache(self, bci)
Sets a persistent cache to use.
source_enabled(self, src_name_str, bool)
Note: this doesn't check against the source catalog (srccat initialized sources as they are first encountered...)
source_request_status = lockfnc(*args, **kwargs)
suppress_queries(self, do_sup)
update(self, msg)
msg is an object of type reqspool.RequestOrderResponse

Static methods defined here:
load_session(name)
Loads a session.

Data descriptors defined here:
seeds
Returns the seeds (user-specified queries).

Data and other attributes defined here:
ent_state_lock = <thread.lock object at 0x7ff12140>
spoolerStatusLock = <thread.lock object at 0x7ff12150>

Methods inherited from Browser:
add_cache_hit_listener(self, c_listener)

 
class BowserSessionStore
    Class used to store information on a Bowser session for serialization.
 
  Methods defined here:
__init__(self, cat, seeds, states, loaded, pending, data_dir_serial)

 
class Browser
    Abstract class for a browsing engine. Concrete browsing engines should
extend this.
 
  Methods defined here:
add_cache_hit_listener(self, c_listener)
add_instance_listener(self, inst_listener)
add_link_listener(self, lnk_listener)
add_query_listener(self, q_listener)
expand(self, src_name, id_name)
is_busy(self)
loaded_instance(self, ref, scls, db)
loaded_link(self, ref, clink, db)
seed(self, source, cls, prop, value)

 
class BrowserCacheInterface
    Abstract interface for checking the contents of a cache.
Basic functionality is checking if a record is in the cache,
and retrieving the record in the cache.
 
  Methods defined here:
add_dataset(self, ds)
Adds a dataset to the cache (leave it to invidual implementing caches
to determine how to handle duplicates, overwriting, etc.)
get_record(self, source_str, ref_str)
Returns the record defined by the source and reference (key).
Throws a NoHitException otherwise.
has_record(self, source_str, ref_str)
Returns True if the record is in the cache, False otherwise.

 
class DataSetGeneratorExecutor(pydi.reqspool.RequestExecutor)
    Request content is in the form of a DataSetGenerator.
 
  Methods defined here:
__init__(self, req, plock=None)
execute_request(self)
The object should be a DataSetGenerator.

Methods inherited from pydi.reqspool.RequestExecutor:
set_request(self, req)

 
class InvalidExpandableError(exceptions.Exception)
    
Method resolution order:
InvalidExpandableError
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 NoHitException(exceptions.Exception)
    
Method resolution order:
NoHitException
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 SpoolingRequestError(exceptions.Exception)
    
Method resolution order:
SpoolingRequestError
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 TimedLock
    Acts like threading.Lock, but there is a specifiable delay after the lock is released.
 
  Methods defined here:
__init__(self, sleep_sec, label=None)
acquire(self)
get_label(self)
release(self)

Data descriptors defined here:
label

 
Functions
       
BrowserEngine(schm_loc)
Method takes the string location of a schema file (as parsable by sexpparse),
and the string name of the generator module for the sources (without the extension).
auto_expand_browser(browser, max_exp, timeout=1200)
Expands the browser to the max_exp number of expand_all operations.
constant_expand_browser(browser, timeout=1200)
Constantly expands the browser; ends when timeout is reached or an expand yields a
not busy signal during polling.

 
Data
        __warningregistry__ = {("Problems encountered importing module 'toy_sources'; check sys.path and try again.", <type 'exceptions.UserWarning'>, 53): 1}
m = 'toy_sources'