etiquette/frontends/etiquette_flask/backend/helpers.py
Ethan Dalool 6e312bd287 Rename the etiquette_flask backend package to backend.
Alright, I got tired of confusing myself with the same-named
outer and inner package.
Keep in mind that every frontend implementation is supposed to be
its own independent project where etiquette is nothing but a
dependency. So the name backend is not ambiguous with the etiquette
backend.
2018-11-04 19:45:23 -08:00

15 lines
344 B
Python

def dict_to_params(d):
'''
Given a dictionary of URL parameters, return a URL parameter string.
{'a':1, 'b':2} -> '?a=1&b=2'
'''
if not d:
return ''
params = [f'{key}={value}' for (key, value) in d.items() if value]
params = '&'.join(params)
if params:
params = '?' + params
return params