Function to manage self-registering plugins
The design is based on http://effbot.org/zone/metaclass-plugins.htm
To register the plugin, the module must be imported by the Python process using it.
Mount point for plugins which refer to actions that can be performed.
Plugins implementing this reference should provide the following method:
run(layers)
layers | A list of layers |
result | A list of layers |
Clip data to boundaries and aggregate their values for each.
data: Point or Raster dataset boundaries: Polygon dataset attribute_name: Name of attribute to aggrate over.
This is only applicable for vector data
aggregation_function: Function to apply (‘count’ or ‘sum’)
Clip data to boundaries and aggregate their values for each.
Aggregated values depend on aggregation function: ‘sum’: Sum of values for attribute_name ‘count’: Dictionary with counts of occurences of each value
of attribute_name
Fetches all the layers that match the plugin requirements.
Extract layers with specified keyword/value pair
Format integer with separator between thousands.
# FIXME (Ole) Currently not using locale coz broken
Instead use this: http://docs.python.org/library/string.html#formatspec
Get plugins that match specified keywords
- Input
- keywords: Either dictionary or list of dictionaries containing
layer keywords of the form {‘category’: ‘hazard’, ‘subcategory’: ‘flood’, ...}
If None or empty all plugins are returned
# name: Optional impact function name (or part of function name) # used to further filter the result. # If None all names are considered to match
- Output
- Dictionary of impact functions ({name: class})
Collect documentaion of a impact function and return it as a dictionary
author : string (identified by :author) synopsis : string (first line) rating : integer (identified by :rating) param_req : list of param (identified by :param requires) detail : detail description (function properties) citation : list of citation in string (function properties) limitation : string (function properties)
Get exposure layer from list of layers
If there are more than one, only the first is returned. Use get_hazard_layers if more are expected and needed
If no layers fit the description None is returned
Get list of layers that have category==’exposure’
Get title for impact function
Get hazard layer from list of layers
If there are more than one, only the first is returned. Use get_hazard_layers if more are expected and needed
If no layers fit the description None is returned
Get list of layers that have category==’hazard’
Get plugin that matches given name
This is just a wrapper around get_plugins to simplify the overly complicated way of extracting the function
Retrieve a list of plugins that match the name you pass
Or all of them if no name is passed.
Retrieve a table listing all plugins and their requirements.
Or just a single plugin if name is passed.
Raises: None
Rephrase the question asked
Extract thresholds form layer keywords if present
Get unique possible value for each column in impact functions doc table.
Args: None
Check whether a function is enabled or not :param func: :return: False is disabled param is True
Parse single requirement from impact function’s doc to category, subcategory, layertype, datatype, unit, and disabled.
Return a human readable name for the function if the function has a func.plugin_name use this otherwise turn underscores to spaces and Caps to spaces
Checks a dictionary params against the requirements defined in require_str. Require_str must be a valid python expression and evaluate to True or False
Collect the requirements from the plugin function doc
The layer keywords are put into the local name space each requires should be on a new line a ‘’ at the end of a line will be a continuation
returns a (possibly empty) list of Python expressions
Example of valid requirements expression :param requires category==’hazard’ and subcategory in [‘flood’, ‘tsunami’] and layertype==’raster’ and unit==’m’
Checks the plugin can run with a given layer.
Based on the requirements specified in the doc string.
This module forms part of the InaSAFE tool.