funpack.custom

This module provides infrastructure for registering and accessing funpack plugins - custom functions for sniffing and loading data files, and for cleaning and processing.

The following plugin types currently exist:

Plugin type

sniffer

Return information about the columns in a file

loader

Load data from a file

cleaner

Run a cleaning function on a single column

processor

Run a processing function on one or more data columns

metaproc

Run a function on a Column metadata value

formatter

Format a column for output

exporter

Export the processed data set

To ensure that the funpack command line help and generated documentation is nicely formatted, all plugin functions should have a docstring of the form:

"""functionSignature(args)
Short description of function on a single line.

Extended description
"""

clearRegistry

Clears and resets the contents of the PluginRegistry.

loadPluginFile

Loads the given file, assumed to be a Python module containing funpack plugin functions.

registerPlugin

Decorator to register a plugin.

registerBuiltIns

Ensures that all built-in plugins are in the registry.

listPlugins

List plugins of the specified type.

exists

Returns True if the given plugin exists, False otherwise.

get

Return a reference to the specified plugin.

args

Return a dict containing any arguments for the specified plugin.

run

Run the specified plugin.

class funpack.custom.PluginRegistry[source]

Bases: object

The PluginRegistry keeps track of, and provides access to all registered plugins.

A singleton PluginRegistry is created at first import of this module, and module-level aliases for all of its methods are created - see below, after the class definition.

args(pluginType, pluginName)[source]

Return a dict containing any arguments for the specified plugin.

clearRegistry()[source]

Clears and resets the contents of the PluginRegistry.

exists(pluginType, pluginName)[source]

Returns True if the given plugin exists, False otherwise.

get(pluginType, pluginName)[source]

Return a reference to the specified plugin.

listPlugins(pluginType)[source]

List plugins of the specified type.

loadPluginFile(filename)[source]

Loads the given file, assumed to be a Python module containing funpack plugin functions.

registerPlugin(pluginType, pluginName=None, **kwargs)[source]

Decorator to register a plugin. If name is not provided, the name of the decorated function is used.

run(pluginType, pluginName, *args, **kwargs)[source]

Run the specified plugin.

funpack.custom.args(pluginType, pluginName)

Return a dict containing any arguments for the specified plugin.

funpack.custom.cleaner(pluginName=None, **kwargs)

Decorator to register a plugin. If name is not provided, the name of the decorated function is used.

funpack.custom.clearRegistry()

Clears and resets the contents of the PluginRegistry.

funpack.custom.exists(pluginType, pluginName)

Returns True if the given plugin exists, False otherwise.

funpack.custom.exporter(pluginName=None, **kwargs)

Decorator to register a plugin. If name is not provided, the name of the decorated function is used.

funpack.custom.formatter(pluginName=None, **kwargs)

Decorator to register a plugin. If name is not provided, the name of the decorated function is used.

funpack.custom.get(pluginType, pluginName)

Return a reference to the specified plugin.

funpack.custom.listPlugins(pluginType)

List plugins of the specified type.

funpack.custom.loadPluginFile(filename)

Loads the given file, assumed to be a Python module containing funpack plugin functions.

funpack.custom.loader(pluginName=None, **kwargs)

Decorator to register a plugin. If name is not provided, the name of the decorated function is used.

funpack.custom.metaproc(pluginName=None, **kwargs)

Decorator to register a plugin. If name is not provided, the name of the decorated function is used.

funpack.custom.processor(pluginName=None, **kwargs)

Decorator to register a plugin. If name is not provided, the name of the decorated function is used.

funpack.custom.registerBuiltIns()[source]

Ensures that all built-in plugins are in the registry.

funpack.custom.registerPlugin(pluginType, pluginName=None, **kwargs)

Decorator to register a plugin. If name is not provided, the name of the decorated function is used.

funpack.custom.run(pluginType, pluginName, *args, **kwargs)

Run the specified plugin.

funpack.custom.runCleaner(pluginName, *args, **kwargs)

Run the specified plugin.

funpack.custom.runExporter(pluginName, *args, **kwargs)

Run the specified plugin.

funpack.custom.runFormatter(pluginName, *args, **kwargs)

Run the specified plugin.

funpack.custom.runLoader(pluginName, *args, **kwargs)

Run the specified plugin.

funpack.custom.runMetaproc(pluginName, *args, **kwargs)

Run the specified plugin.

funpack.custom.runProcessor(pluginName, *args, **kwargs)

Run the specified plugin.

funpack.custom.runSniffer(pluginName, *args, **kwargs)

Run the specified plugin.

funpack.custom.sniffer(pluginName=None, **kwargs)

Decorator to register a plugin. If name is not provided, the name of the decorated function is used.