PyOpenWorm.command module¶
-
exception
PyOpenWorm.command.
GenericUserError
[source]¶ Bases:
Exception
An error which should be reported to the user. Not necessarily an error that is the user’s fault
-
exception
PyOpenWorm.command.
InvalidGraphException
[source]¶ Bases:
PyOpenWorm.command.GenericUserError
Thrown when a graph cannot be translated due to formatting errors
-
exception
PyOpenWorm.command.
UnreadableGraphException
[source]¶ Bases:
PyOpenWorm.command.GenericUserError
Thrown when a graph cannot be read due to it being missing, the active user lacking permissions, etc.
-
class
PyOpenWorm.command.
POW
[source]¶ Bases:
object
High-level commands for working with PyOpenWorm data
-
add_graph
(self, 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
(self, 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
(self, message)[source]¶ Write the graph to the local repository
Parameters: - message : str
commit message
-
context
(self, context=None, user=False)[source]¶ Read or set current target context for the repository
Parameters: - context : str
The context to set
- user : bool
If set, set the context only for the current user. Has no effect for retrieving the context
-
diff
(self)[source]¶ Show differences between what’s in the working context set and what’s in the serializations
-
git
(self, *args)[source]¶ Runs git commmands in the .pow directory
Parameters: - *args
arguments to git
-
imports_context
(self, context=None, user=False)[source]¶ Read or set current target imports context for the repository
Parameters: - context : str
The context to set
- user : bool
If set, set the context only for the current user. Has no effect for retrieving the context
-
init
(self, 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
-
reconstitute
(self, 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
-
save
(self, module, provider=None, context=None)[source]¶ Save the data in the given context
Saves the “mapped” classes declared in a module and saves the objects declared by the “provider” (see the argument’s description)
Parameters: - module : str
Name of the module housing the provider
- provider : str
Name of the provider, a callble that accepts a context object and adds statements to it. Can be a “dotted” name indicating attribute accesses
- context : str
The target context
-
say
(self, subject, property, object)[source]¶ Make a statement
Parameters: - subject : str
The object which you want to say something about
- property : str
The type of statement to make
- object : str
The other object you want to say something about
-
serialize
(self, context=None, destination=None, format='nquads', include_imports=False, whole_graph=False)[source]¶ Serialize the current data context or the one provided
Parameters: - context : str
The context to save
- destination : file or str
A file-like object to write the file to or a file name. If not provided, messages the result.
- format : str
Serialization format (ex, ‘n3’, ‘nquads’)
- include_imports : bool
If true, then include contexts imported by the provided context in the result. The default is not to include imported contexts.
- whole_graph: bool
Serialize all contexts from all graphs (this probably isn’t what you want)
-
translate
(self, translator, output_key=None, output_identifier=None, data_sources=(), named_data_sources=None)[source]¶ Do a translation with the named translator and inputs
Parameters: - translator : str
Translator identifier
- imports_context_ident : str
Identifier for the imports context. All imports go in here
- output_key : str
Output key. Used for generating the output’s identifier. Exclusive with output_identifier
- output_identifier : str
Output identifier. Exclusive with output_key
- data_sources : list of str
Input data sources
- named_data_sources : dict
Named input data sources
-
config_file
¶ The config file name
-
log_level
¶ Log level
-
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
(self, 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
(self, context=None, kind=None, full=False)[source]¶ List known sources
Parameters: - kind : str
Only list sources of this kind
- context : str
The context to query for sources
- full : bool
Whether to (attempt to) shorten the source URIs by using the namespace manager
-
list_kinds
(self, full=False)[source]¶ List kinds of sources
Parameters: - full : bool
Whether to (attempt to) shorten the source URIs by using the namespace manager
-
data
¶ Commands for saving and loading data for DataSources
-
-
class
PyOpenWorm.command.
POWSourceData
(parent)[source]¶ Bases:
object
Commands for saving and loading data for DataSources
-
retrieve
(self, source, archive='data.tar', archive_type=None)[source]¶ Retrieves the data for the source
Parameters: - source : str
The source for data
- archive : str
The file name of the archive. If this ends with an extension like ‘.zip’, and no archive_type argument is given, then an archive will be created of that type. The archive name will not have any extension appended in any case.
- archive_type : str
The type of the archive to create.
-
-
class
PyOpenWorm.command.
SaveValidationFailureRecord
(user_module, stack, validation_record)[source]¶