forked from dimagi/commcare-hq
/
api.py
42 lines (34 loc) · 1.07 KB
/
api.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
class ReportDataSource(object):
slug = ''
def __init__(self, config=None):
"""
:param config: dictionary containing configuration for this data source.
e.g.
{
'startdate': date(2013, 1, 1),
'enddate': date(2013, 1, 31),
'user_id': 'abc'
}
"""
self.config = config or {}
def configure(self, config):
"""
:param config: dictionary containing configuration for this data source.
Overrides any config supplied to the constructor.
"""
self.config = config
def slugs(self):
"""
Intention: Override
:return: A list of available slugs.
"""
return []
def get_data(self, slugs=None):
"""
Intention: Override
:param slugs: List of slugs to return for each row. Return all values if slugs = None or [].
:return: A list of dictionaries mapping slugs to values.
e.g.
[{'village': 'Mazu', 'births': 30, 'deaths': 28},{...}]
"""
return {}