Added all the main files of the library
This commit is contained in:
24
utils.py
Normal file
24
utils.py
Normal file
@@ -0,0 +1,24 @@
|
||||
def sorted_params_string(filters_dict):
|
||||
"""
|
||||
This function takes a dict and returns it in a sorted form for the url filter, it's primarily used for cache purposes.
|
||||
"""
|
||||
filters_string = ''
|
||||
for key in sorted(filters_dict.keys()):
|
||||
if filters_string == '':
|
||||
filters_string = f"{key}={','.join(str(val) for val in sorted(filters_dict[key]))}"
|
||||
else:
|
||||
filters_string = f"{filters_string}&{key}={','.join(str(val) for val in sorted(filters_dict[key]))}"
|
||||
filters_string = filters_string.strip()
|
||||
return filters_string
|
||||
|
||||
|
||||
def parse_tags_to_dict(tags):
|
||||
tagdict = {}
|
||||
if ':' not in tags:
|
||||
tagdict = {}
|
||||
else:
|
||||
for subtag in tags.split('&'):
|
||||
tagkey, taglist = subtag.split(':')
|
||||
taglist = taglist.split(',')
|
||||
tagdict[tagkey] = set(taglist)
|
||||
return tagdict
|
||||
Reference in New Issue
Block a user