opyenxes.extension package

Submodules

opyenxes.extension.XExtension module

class opyenxes.extension.XExtension.XExtension(name, prefix, uri)[source]

Bases: object

This class defines and implements extensions to the basic log meta-model. Extensions have a name, a defined prefix, and a unique URI. They can define additional, typed attributes on the level of the log, trace, and event. Also, extensions may define meta attributes

Parameters:
  • name (str) – The name of the extension.
  • prefix (str) – Prefix string of the extension, used for addressing attributes.
  • uri (urllib.parse.ParseResult or urllib.parse.SplitResult) – Unique URI of the extension. This URI should point to the file defining the extension, and must be able to be resolved. Extension files should be accessible over the internet, e.g. stored on web servers.
get_defined_attributes()[source]

Returns the collection of attributes defined by this extension for any log elements (archive-, log-, trace-, event-, and meta-attributes).

Returns:The collection of attributes defined by this extension
Return type:set
get_event_attributes()[source]

Returns the collection of attributes defined by this extension for event elements.

Returns:The collection of attributes for event elements
Return type:set
get_log_attributes()[source]

Returns the collection of attributes defined by this extension for log elements.

Returns:the collection of attributes for log elements
Return type:set
get_meta_attributes()[source]

Return the collection of meta-attributes defined by this extension for attributes.

Returns:The collection of meta-attributes for attributes.
Return type:set
get_name()[source]

Returns the human-readable name of this extension.

Returns:The name of this extension.
Return type:str
get_prefix()[source]

Returns a unique prefix associated with this extension. This prefix should be no longer than 5 characters, so as not to unnecessarily blow up storage files.

Returns:An unique prefix associated with this extension
Return type:str
get_trace_attributes()[source]

Returns the collection of attributes defined by this extension for trace elements.

Returns:the collection of attributes for trace elements
Return type:set
get_uri()[source]

Returns a unique URI associated with this extension. This URI should point to the file defining the extension, and must be able to be resolved. Extension files should be accessible over the internet, e.g. stored on web servers.

Returns:An unique URI associated with this extension
Return type:urllib.parse.ParseResult or urllib.parse.SplitResult

opyenxes.extension.XExtensionManager module

class opyenxes.extension.XExtensionManager.XExtensionManager[source]

Bases: object

The extension manager is used to access, store, and manage extensions in a system. Extensions can be loaded from their given URI, which should point to the file defining the extension. Also, extensions can be registered locally, which then override any remotely-loaded extensions (which are more generic placeholders). Extension files downloaded from remote sources (which happens when the extension cannot be resolved locally) are cached on the local system, so that the network source of extension files is not put under extensive stress. The extension manager is a singleton, there is no need to instantiate more than one extension manager, which is necessary to avoid states of inconsistency.

Uses the singleton metaclass

static cache_extension(uri)[source]

Downloads and caches an extension from its remote definition file. The extension is subsequently placed in the local cache, so that future loading is accelerated.

Parameters:uri (urllib.parse.ParseResult or urllib.parse.SplitResult) – Unique URI of the extension which is to be cached.
get_by_index(index)[source]

Retrieves an extension by ints index. If no extension with the given index is found, this method returns null.

Parameters:index (int) – The index of the requested extension.
Returns:The requested extension (may be null, if it cannot be found).
Return type:XExtension
get_by_name(name)[source]

Retrieves an extension by its name. If no extension by that name can be found, this method returns null.

Parameters:name (str) – The name of the requested extension.
Returns:The requested extension (may be null, if it cannot be found).
Return type:XExtension
get_by_prefix(prefix)[source]

Retrieves an extension by its prefix. If no extension by that prefix can be found, this method returns null.

Parameters:prefix (str) – The prefix of the requested extension.
Returns:The requested extension (may be null, if it cannot be found).
Return type:XExtension
get_by_uri(uri)[source]

Retrieves an extension instance by its unique URI. If the extension has not been registered before, it is looked up in the local cache. If it cannot be found in the cache, the manager attempts to download it from its unique URI, and add it to the set of managed extensions.

Parameters:uri (urllib.parse.ParseResult or urllib.parse.SplitResult) – The unique URI of the requested extension.
Returns:The requested extension.
Return type:XExtension
get_index(extension)[source]

Resolves the index of an extension, given that this extension has been previously registered with this manager instance. If the given index has not been registered previously, this method returns -1.

Parameters:extension (XExtension) – The extension to look up the index for.
Returns:Unique index of the requested extension (positive integer).
Return type:int
load_extension_cache()[source]

Loads all extensions stored in the local cache. Cached extensions which exceed the maximum caching age are discarded, and downloaded freshly.

register(extension)[source]

Explicitly registers an extension instance with the extension manager.

Parameters:extension (XExtension) – The extension to be registered.
register_standard_extensions()[source]

Registers all defined standard extensions with the extension manager before caching.

opyenxes.extension.XExtensionParser module

class opyenxes.extension.XExtensionParser.XExtensionParser[source]

Bases: object

Parser for extension definition files.

Uses the singleton metaclass

class XExtensionHandler[source]

Bases: xml.sax.handler.ContentHandler

SAX handler class for extension definition files.

endElement(local_name)[source]

Overrides endElement in class ContentHandler

Parameters:local_name (str) – The name of the element type, just as with the startElement event
get_extension()[source]

Retrieves the parsed extension after parsing.

Returns:The parsed extension.
Return type:XExtension
reset()[source]

Resets the handler to initial state.

startElement(name, attributes)[source]

Overrides startElement in class ContentHandler

Parameters:
  • name (str) – Contains the raw XML 1.0 name of the element type
  • attributes (xml.sax.xmlreader.AttributesImpl) – An instance of the Attributes class containing the attributes of the element
static parse(file)[source]

Parses an extension from a definition file.

Parameters:file (str) – The path of the file containing the extension or url string which represents the extension definition file..
Returns:The extension object, as defined in the provided file.
Return type:XExtension

Module contents