Typos make the world go round

This commit is contained in:
2023-08-30 03:57:38 +03:00
parent c234f7b1ce
commit c1fd01a6d8
5 changed files with 1364 additions and 0 deletions

View 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