PyOpenWorm.command module

exception PyOpenWorm.command.InvalidGraphException[source]

Bases: exceptions.Exception

exception PyOpenWorm.command.UnreadableGraphException[source]

Bases: exceptions.Exception

class PyOpenWorm.command.POW[source]

Bases: object

High-level commands for working with PyOpenWorm data

add_graph(url=None, context=None, include_imports=True)[source]

Fetch a graph and add it to the local store.

Parameters:
url : str

The URL of the graph to fetch

context : rdflib.term.URIRef

If provided, only this context and, optionally, its imported graphs will be added.

include_imports : bool

If True, imports of the named context will be included. Has no effect if context is None.

clone(url=None, update_existing_config=False)[source]

Clone a data store

Parameters:
url : str

URL of the data store to clone

update_existing_config : bool

If True, updates the existing config file to point to the given file for the store configuration

commit(message)[source]

Write the graph to the local repository

Parameters:
message : str

commit message

diff()[source]
fetch_graph(url)[source]

Fetch a graph

Parameters:
url : str

URL for the graph

init(update_existing_config=False)[source]

Makes a new graph store.

The configuration file will be created if it does not exist. If it does exist, the location of the database store will, by default, not be changed in that file

Parameters:
update_existing_config : bool

If True, updates the existing config file to point to the given file for the store configuration

list_contexts()[source]

List contexts

merge()[source]
push()[source]
reconstitute(data_source)[source]

Recreate a data source by executing the chain of translators that went into making it.

Parameters:
data_source : str

Identifier for the data source to reconstitute

serialize(destination, format='nquads')[source]

Serialize the graph to a file

Parameters:
destination : file or str

A file-like object to write the file to or a file name

format : str

Serialization format (ex, ‘n3’, ‘nquads’)

tag()[source]
translate(translator, output_key=None, *data_sources, **named_data_sources)[source]

Do a translation with the named translator and inputs

Parameters:
translator : str

Translator identifier

output_key : str

Output identifier

*data_sources : str

Input data sources

**named_data_sources : str

Named input data sources

config_file

The config file name

powdir

The base directory for PyOpenWorm files. The repository provider’s files also go under here

store_name

The file name of the database store

class PyOpenWorm.command.POWSource(parent)[source]

Bases: object

Commands for working with DataSource objects

create(kind, key, *args, **kwargs)[source]

Create the source and add it to the graph.

Arguments are determined by the type of the data source

Parameters:
kind : rdflib.term.URIRef

The kind of source to create

key : str

The key, a unique name for the source

list(context=None)[source]

List known sources

list_kinds()[source]

List kinds of sources