Skip to content

Commit 35bc53f

Browse files
authored
Merge pull request #44 from ocefpaf/fix_43
Closes #43
2 parents 5060539 + 2ced0c1 commit 35bc53f

File tree

2 files changed

+11
-19
lines changed

2 files changed

+11
-19
lines changed

CHANGES.txt

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## 0.1.7
4+
5+
- Fixed bug that preventing from generating download URLs with no data
6+
constraints or variables.
7+
38
## 0.1.6
49

510
- Simplify the `erddapy` object constructor.

erddapy/url_builder.py

+6-19
Original file line numberDiff line numberDiff line change
@@ -152,32 +152,19 @@ def download_url(server, dataset_id, protocol, variables, response='html', const
152152
url (str): the download URL for the `response` chosen.
153153
154154
"""
155-
base = '{server_url}/{protocol}/{dataset_id}'
155+
url = f'{server}/{protocol}/{dataset_id}.{response}?'
156156

157-
if not constraints:
158-
url = base.format(
159-
server_url=server,
160-
protocol=protocol,
161-
dataset_id=dataset_id
162-
)
163-
else:
164-
base += '.{response}?{variables}{constraints}'
157+
if variables:
158+
variables = ','.join(variables)
159+
url += f'{variables}'
165160

161+
if constraints:
166162
_constraints = copy.copy(constraints)
167163
for k, v in _constraints.items():
168164
if k.startswith('time'):
169165
_constraints.update({k: parse_dates(v)})
170-
171166
_constraints = quote_string_constraints(_constraints)
172167
_constraints = ''.join(['&{}{}'.format(k, v) for k, v in _constraints.items()])
173-
variables = ','.join(variables)
174168

175-
url = base.format(
176-
server_url=server,
177-
protocol=protocol,
178-
dataset_id=dataset_id,
179-
response=response,
180-
variables=variables,
181-
constraints=_constraints
182-
)
169+
url += f'{_constraints}'
183170
return _check_url_response(url)

0 commit comments

Comments
 (0)