modilabs/pybamboo — pull request #27 by rgaudin (2013-03-11 18:14:37+00:00)
Title: Revamped calculations/aggregations methods

Simplified the way we deal with calculations and aggregation.
I believe we got a little too excited when we started pybamboo and wanted
to add too much value to it.

I think that until we have users' requests and documentation, we should keep close
to the actual Bamboo API.

I thus removed the notion of aggregation since bamboo doesn't use such language.

To work with them, now we have:

* `add_calculation(name='sum_of_amount', formula='sum(amount)', groups=['food_type,something_else', 'another'])`
* `add_calculations(path='/tmp/my_calcs.json')`
* `add_calculations(json=[{"name": "sum_of_amount", "formula": "sum(amount)", "groups": ["risk_factor", "food_type"]}])`
* `add_calculations(content='[{"formula": "sum(amount)", "name": "sum_of_amount", "groups": ["risk_factor", "food_type"]}]')`

* `remove_calculation(name)`
* `get_calculations()`
* `get_aggregate_datasets` # added a get_aggregations() alias for it to match bamboo API name

Simpler right ?

So I removed the following:
* `add_calculation(formula)` # managing the formula string by hand seems anti-pythonic.
* `_split_formula(formula)` # dependency of above.
* `_is_formula_an_aggregation(formula)` # idem.
* `_process_formula(formula, is_aggregation=False, as_dict=False)` # idem.
* `add_calculations(formulae)` # used to batch calculation creation as a list of previouly formatted strings. Now we'd just send a list of dicts.
* `add_aggregation(formula, groups=None)` # was a `shortcut` to calculation with a group. Useless.

Tests have all been adapted and passes.