Onyx was originally developed at the Human Language Technology Center of Excellence at Johns Hopkins University.
platform - A string encoding the runtime platform. It consists of five parts separated by dash: platform, os, architecture, native data-width, endianness
E.g. darwin-posix-i386-32bit-le
home - A string of the absolute path to the top-level directory of the Onyx installation from which this onyx package was imported.
Bases: onyx.OnyxException
The DataFormatError is raised when an inconsistency is detected in the internal structure of some data.
For example, while reading audio data, this exception will be raised if the amount of data in the file differs from what the file header promised, or if decoding of data fails due to corruption, etc.
>>> import onyx
>>> e = onyx.DataFormatError()
>>> type(e), type(e).__bases__
(<class 'onyx.DataFormatError'>, (<class 'onyx.OnyxException'>,))
Bases: onyx.OnyxException
The DataTypeError exception is raised when the type of some data is incorrect or cannot be determined.
For example, when trying to read audio data, this exception will be raised if the type of audio data in a file cannot be determined from the file header.
>>> import onyx
>>> e = onyx.DataTypeError()
>>> type(e), type(e).__bases__
(<class 'onyx.DataTypeError'>, (<class 'onyx.OnyxException'>,))
Bases: onyx.OnyxException
The ExternalError is used when an exception must be raised due to an error condition occuring outside of Python or the project’s Python code.
ExternalError is most often used when an error condition is reported or determined from the results of a subprocess or a system call and that error condition cannot readily be interpreted as one of the standard Python exceptions.
>>> import onyx
>>> e = onyx.ExternalError()
>>> type(e), type(e).__bases__
(<class 'onyx.ExternalError'>, (<class 'onyx.OnyxException'>,))
Bases: exceptions.Exception
Baseclass for exceptions generated by logic within the project.
This is a subclass of Python’s Exception class. Subclasses of this exception are raised when something unexpected happens within the logic of project’s code. Note: it does not replace standard Python runtime exceptions, e.g. TypeError and ValueError, which are raised from within the project when an interface is misused.
>>> import onyx
>>> e = onyx.OnyxException("something went wrong")
>>> type(e), type(e).__bases__
(<class 'onyx.OnyxException'>, (<type 'exceptions.Exception'>,))
>>> try: raise e
... except onyx.OnyxException, ee:
... print ee
something went wrong
Bases: exceptions.EnvironmentError, onyx.ExternalError
Exception raised when communication with a subprocess fails.
In addition to being an ExternalError, this is a subclass of Python’s EnvironmentError, and supports EnvironmentError’s interface: http://docs.python.org/lib/module-exceptions.html
>>> x = SubprocessError(1, "foo")
>>> isinstance(x, EnvironmentError), isinstance(x, ExternalError)
(True, True)
>>> x.errno, x.strerror, x.filename
(1, 'foo', None)
>>> str(x)
'[Errno 1] foo'
>>> x = SubprocessError(1, "foo", "bar")
>>> x.errno, x.strerror, x.filename
(1, 'foo', 'bar')
>>> str(x)
"[Errno 1] foo: 'bar'"
>>> x = SubprocessError(1)
>>> x.errno, x.strerror, x.filename
(None, None, None)
>>> str(x)
'1'
>>> x = SubprocessError(1, 'foo', 'bar', 'baz')
>>> x.errno, x.strerror, x.filename
(None, None, None)
>>> str(x)
"(1, 'foo', 'bar', 'baz')"
exception errno
exception filename
exception strerror
Boilerplate function called explicitly by almost every Onyx module when run as standalone script. It does the doctest work on a module and reports summary statistics. It is called from the if __name__ == '__main__': clause at the bottom of most modules. It is intended that this function be called by modules that are also scripts, typically prior to argument parsing and the actual work of the script.
If there are no command-line arguments, this function logs the result message, and if there were failures it calls sys.exit() with the number of failures.
If there are command-line arguments and there were no failures then nothing gets logged – this silence supports the module’s use as a script. If there are command-line arguments and there were failures, then the result message is logged to both stdout and stderr, but sys.exit() is not called.
Note: this doctest-calling function is difficult to test explicitly via the doctest facility, particularly its failure modes. So there’s no doctest in this documentation string.