PyOpenWorm package

PyOpenWorm

OpenWorm Unified Data Abstract Layer.

An introduction to PyOpenWorm can be found in the README on our Github page.

Most statements correspond to some action on the database. Some of these actions may be complex, but intuitively a.B(), the Query form, will query against the database for the value or values that are related to a through B; on the other hand, a.B(c), the Update form, will add a statement to the database that a relates to c through B. For the Update form, a Relationship object describing the relationship stated is returned as a side-effect of the update.

The Update form can also be accessed through the set() method of a Property and the Query form through the get() method like:

a.B.set(c)

and:

a.B.get()

The get() method also allows for parameterizing the query in ways specific to the Property.

Relationship objects are key to the Evidence class for sourcing statements. Relationships can themselves be members in a relationship, allowing for fairly complex hierarchical statements to be made about entities.

Notes:

  • Of course, when these methods communicate with an external database, they may fail due to the database being unavailable and the user should be notified if a connection cannot be established in a reasonable time. Also, some objects are created by querying the database; these may be made out-of-date in that case.
  • a : {x_0,...,x_n} means a could have the value of any one of x_0 through x_n
PyOpenWorm.loadConfig(f)[source]

Load configuration for the module.

PyOpenWorm.loadData(data='OpenWormData/WormData.n3', dataFormat='n3', skipIfNewer=False)[source]

Load data into the underlying database of this library.

XXX: This is only guaranteed to work with the ZODB database.

Parameters:
  • data – (Optional) Specify the file to load into the library
  • dataFormat – (Optional) Specify the file format to load into the library. Currently n3 is supported
  • skipIfNewer – (Optional) Skips loading of data if the database file is newer than the data to be loaded in. This is determined by the modified time on the main database file compared to the modified time on the data file.
PyOpenWorm.disconnect(c=False)[source]

Close the database.

PyOpenWorm.connect(configFile=False, conf=False, do_logging=False, data=False, dataFormat='n3')[source]
Load desired configuration and open the database
Parameters:
  • configFile – (Optional) The configuration file for PyOpenWorm
  • conf – (Optional) If true, initializes a data object with the PyOpenWorm configuration
  • do_logging – (Optional) If true, turn on debug level logging
  • data – (Optional) If provided, specify the file to load into the library
  • dataFormat – (Optional) If provided, specify the file format to load into the library. Currently n3 is supported
PyOpenWorm.config(key=None)[source]

Gets the main configuration for the whole PyOpenWorm library.

Returns:the instance of the Configure class currently operating.