Skip to content

Commit 00cf9c0

Browse files
committed
Added docstrings
1 parent 46b7a2b commit 00cf9c0

File tree

3 files changed

+60
-5
lines changed

3 files changed

+60
-5
lines changed

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747

4848
# General information about the project.
4949
project = 'GHOclient'
50-
copyright = "2020, Flávio Codeço Coelho"
50+
copyright = "2020-21, Flávio Codeço Coelho"
5151
author = "Flávio Codeço Coelho"
5252

5353
# The version info for the project you're documenting, acts as replacement

ghoclient/ghoclient.py

Lines changed: 58 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,52 @@ def __init__(self):
1717
self.data = xmltodict.parse(resp.text)
1818

1919
def get_available_datasets(self):
20+
'''
21+
Check for available datasets
22+
23+
Returns
24+
-------
25+
datasets : list
26+
list of datasets.
27+
28+
'''
2029
datasets = []
2130
for k, v in self.data['GHO']['Metadata'].items():
2231
if k == 'Dataset':
2332
datasets.extend([d for d in v])
2433
return datasets
2534

2635
def get_attributes(self):
36+
'''
37+
Lists attributes used on datasets
38+
39+
Returns
40+
-------
41+
attributes : list
42+
list of attributes represented as dictionaries.
43+
44+
'''
2745
attributes = []
2846
for k, v in self.data['GHO']['Metadata'].items():
2947
if k == 'Attribute':
3048
attributes.extend([d for d in v])
3149
return attributes
3250

3351
def get_dimensions(self, format='dataframe'):
52+
'''
53+
List dimensions of data
54+
55+
Parameters
56+
----------
57+
format : str, output format, of `dataframe` (default) or `list`
58+
DESCRIPTION. The default is 'dataframe'.
59+
60+
Returns
61+
-------
62+
dimensions: dataframe or list
63+
description of every variable in the datasets and their dimension.
64+
65+
'''
3466
dimensions = []
3567
for k, v in self.data['GHO']['Metadata'].items():
3668
if k == 'Dimension':
@@ -40,12 +72,35 @@ def get_dimensions(self, format='dataframe'):
4072
return dimensions
4173

4274
def get_region_codes(self):
75+
'''
76+
Returns region codes
77+
78+
Returns
79+
-------
80+
regions : dictionary
81+
Dictionary with code, description pairs.
82+
83+
'''
4384
url = BASE_URL + 'REGION'
4485
data = self._fetch_data_as_dict(url)
45-
regions = [{c['@Label']: c['Display']} for c in data['GHO']['Metadata']['Dimension']['Code']]
86+
regions = {c['@Label']: c['Display'] for c in data['GHO']['Metadata']['Dimension']['Code']}
4687
return regions
4788

4889
def get_countries(self, format='dataframe'):
90+
'''
91+
Returns a dataframe with country codes and metadata
92+
93+
Parameters
94+
----------
95+
format : str, optional
96+
The default is 'dataframe'.
97+
98+
Returns list if `format` is full
99+
-------
100+
data: dataframe by default
101+
country info.
102+
103+
'''
49104
url = BASE_URL + 'COUNTRY'
50105
data = self._fetch_data_as_dict(url)
51106
if format == 'dataframe':
@@ -96,9 +151,9 @@ def _fetch_data_as_dict(self, url):
96151

97152
def get_data_codes(self, format='dataframe'):
98153
"""
99-
Get Codes That
154+
Get Codes that can be fetched as indicators.
100155
:param format: either 'full', 'label' or 'url'
101-
:return: list of dicts when format is full or a list of strings otherwise.
156+
:return: list of dicts when `format` is 'full', a Dataframe when it is 'dataframe' or a list of strings otherwise.
102157
"""
103158
url = BASE_URL + 'GHO'
104159
data = self._fetch_data_as_dict(url)

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,6 @@
4949
test_suite='tests',
5050
tests_require=test_requirements,
5151
url='https://github.com/fccoelho/ghoclient',
52-
version='0.1.0',
52+
version='1.0.2',
5353
zip_safe=False,
5454
)

0 commit comments

Comments
 (0)