Skip to content
Snippets Groups Projects
Commit efe05953 authored by Stefano Borini's avatar Stefano Borini
Browse files

Merge branch 'master' into base-plugin-class

parents 60b37289 53e784be
No related branches found
No related tags found
1 merge request!23Introduces base class for plugins to simplify export
...@@ -42,26 +42,66 @@ class BundleRegistryPlugin(Plugin): ...@@ -42,26 +42,66 @@ class BundleRegistryPlugin(Plugin):
id='force.bdss.kpi_calculators.bundles') id='force.bdss.kpi_calculators.bundles')
def data_source_bundle_by_id(self, id): def data_source_bundle_by_id(self, id):
"""Finds a given data source bundle by means of its id.
The ID is as obtained by the function bundle_id() in the
plugin api.
Parameters
----------
id: str
The identifier returned by the bundle_id() function.
Raises
------
ValueError: if the entry is not found.
"""
for ds in self.data_source_bundles: for ds in self.data_source_bundles:
if ds.id == id: if ds.id == id:
return ds return ds
raise Exception("Requested data source {} but don't know " raise ValueError(
"to find it.".format(id)) "Requested data source {} but don't know how "
"to find it.".format(id))
def kpi_calculator_bundle_by_id(self, id): def kpi_calculator_bundle_by_id(self, id):
"""Finds a given kpi bundle by means of its id.
The ID is as obtained by the function bundle_id() in the
plugin api.
Parameters
----------
id: str
The identifier returned by the bundle_id() function.
Raises
------
ValueError: if the entry is not found.
"""
for kpic in self.kpi_calculator_bundles: for kpic in self.kpi_calculator_bundles:
if kpic.id == id: if kpic.id == id:
return kpic return kpic
raise Exception( raise ValueError(
"Requested kpi calculator {} but don't know " "Requested kpi calculator {} but don't know how "
"to find it.".format(id)) "to find it.".format(id))
def mco_bundle_by_id(self, id): def mco_bundle_by_id(self, id):
"""Finds a given Multi Criteria Optimizer (MCO) bundle by means of
its id. The ID is as obtained by the function bundle_id() in the
plugin api.
Parameters
----------
id: str
The identifier returned by the bundle_id() function.
Raises
------
ValueError: if the entry is not found.
"""
for mco in self.mco_bundles: for mco in self.mco_bundles:
if mco.id == id: if mco.id == id:
return mco return mco
raise Exception("Requested MCO {} but it's not available" raise ValueError("Requested MCO {} but don't know how "
"to compute it.".format(id)) "to find it.".format(id))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment