Command Line Utilities


A command line program, ordf, for running handlers and processing messages. This is somewhat of a swiss-army knife but some of the more common use cases are described below.

-c config.ini, --config config.ini

Some command line options can be specified in the configuration file with a similar syntax. Other than for testing it is almost always going to be desirable to run with a configuration file.

Any options given on the command line will override the corresponding configuration file parameters.

The configuration file should have a section [app:main] for compatibility with pylons configuration files. This configuration section is passed to ordf.handler.init_handler()

-r reader[,reader[...]], --readers reader[,reader[...]]

A comma-separated list of reader plugins. Equivalent to ordf.readers in the configuration file.

-w writer[,writer[...]], --writers writer[,writer[...]]

A comma-separated list of writer plugins. Equivalent to ordf.writers in the configuration file.

-l logfile, --logfile logfile

A file to write log messages to.

-v verbosity, --verbosity verbosity

The minimum level of log messages to write to the file. Must be one of debug, info, warning, error or critical.

-s, --save

Save the arguments to the store.

-x, --remove

Remove the arguments from the store by replacing them with an empty graph.

-f format, --format format

For operations that involve reading RDF data, the format that it is in. This must be one of the formats supported by rdflib. The default is XML.

-i uri, --identifier uri

For operations that involve writing data to the store, the graph identifier that should be the destination of the data. Default is the filename.

-e sub, --edit sub

For importing as opposed to copying a graph from a remote store, pass this sed(1) style substitution command. For example for development one might do:

ordf -c development.ini -s --nocs \
    -e 's@^http://.*' \

It is possible to set these options in the configuration file as well like so:

ordf.edit = ['s@^http://.*']

Unless the –noprov flag is given, these edit operations are recorded in the provenance block of the imported graph.

-u username, --user username

Username for logging changes

-m message, --message message

Log message or change reason for logging changes

-d, --daemon

Run as a daemon, listening to a source and writing data to local storage.


Run in a reloading file monitor, reloading if changes to python code or configuration file are made.


Rebuild indices iterating over a single reader


Utility program for loading any RDF fixtures that are packaged with some python modules. Normal usage is as in:

% ordf_load -p ordf.vocab
INFO  [ordf.handler] Handler(0/0) initialised ver
INFO  [ordf.handler] Handler(1/0) reading from < object ...>
INFO  [ordf.handler] Handler(1/1) writing to < object ...>
INFO  [ordf.handler.rdf.RDFLib] Initialising Sleepycat storage
INFO  [ordf.handler] Handler(1/2) writing to <ordf.handler.rdf.RDFLib object ...>
INFO  [ordf.load/3149] Loading
INFO  [ordf.changeset] 20 changes urn:uuid:44764ed0-8d12-11df-acde-001f5bef60ee

% ordf_load -p ordf.onto
INFO  [ordf.handler] Handler(0/0) initialised ver
INFO  [ordf.handler] Handler(1/0) reading from < ...>
INFO  [ordf.handler] Handler(1/1) writing to < ...>
INFO  [ordf.handler.rdf.RDFLib] Initialising Sleepycat storage
INFO  [ordf.handler] Handler(1/2) writing to <ordf.handler.rdf.RDFLib ...>
INFO  [ordf.load/3148] Loading
INFO  [ordf.load/3148] Loading
INFO  [ordf.load/3148] Loading
INFO  [ordf.load/3148] Loading
INFO  [ordf.changeset] 612 changes urn:uuid:171ffd8c-8d12-11df-850a-001f5bef60ee

In addition to the -c for specifying the config file, -l and -v for log file and debugging, and -r and -w for specifying readers and writers as with ordf, ordf_load supports these arguments:

-p, --package

Name of the package (python module) to look for N3 fixtures in. This doesn’t work with namespace packages (e.g. ordf itself which is why the schema fixtures are in the ordf.vocab sub-module).

Command Implementation – Command

class ordf.command.Command[source]

This class is very similar to paste.script.command.Command but rather than implementing a paster plugin it is for stand-alone command line programs. To implement a command line program, sub-class this class, and make a minimal method to instantiate and run it. As with the paster counterpart you have to add an option parser and a method called command(). A minimal example:

class Hello(Command):
    parser = Command.StandardParser(usage="%prog [options]")
    def command(self):
        print "hello world"

def hello():

To create the actual script, in your package’s needs an entry point like:


and then run one of:

% python develop
% python install

Table Of Contents

Previous topic

Getting Started

Next topic

API Documentation for ordf

This Page