From f41cd316889dcbdc62e22e6622a6ecea4a435084 Mon Sep 17 00:00:00 2001 From: Andrew Date: Sun, 7 Jul 2019 15:40:51 +0400 Subject: =?UTF-8?q?WIP:=20=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD?= =?UTF-8?q?=D0=BE=20=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD=D0=B8=D0=B5?= =?UTF-8?q?=20=D0=BE=D1=82=D0=B4=D0=B5=D0=BB=D1=8C=D0=BD=D1=8B=D1=85=20?= =?UTF-8?q?=D0=BF=D0=BE=D0=BB=D0=B5=D0=B9=20=D0=B2=20=D1=82=D0=B0=D0=B1?= =?UTF-8?q?=D0=BB=D0=B8=D1=86=D0=B5.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- day9/task5/utils.py | 31 ------------------------------- 1 file changed, 31 deletions(-) (limited to 'day9/task5/utils.py') diff --git a/day9/task5/utils.py b/day9/task5/utils.py index 5a48a9f..3e0dc64 100644 --- a/day9/task5/utils.py +++ b/day9/task5/utils.py @@ -74,34 +74,3 @@ def render_template(path, **kwargs): template = template.replace(f'%%{key}%%', kwargs[key]) return template - - -def parse_query(query): - parsed_query = {'expression': {}, 'condition': {}} - - pattern = re.compile(r'(expression|condition)(\d+)_(key|value)') - - for key, (value,) in query.items(): - match = pattern.fullmatch(key) - if match is not None: - index = int(match.group(2)) - if index not in parsed_query[match.group(1)]: - parsed_query[match.group(1)][index] = {} - - parsed_query[match.group(1)][index][match.group(3)] = value - - expressions = [] - for expression in parsed_query['expression'].values(): - expressions.append('`{}`="{}"'.format( - expression['key'], expression['value'] - )) - expressions = ','.join(expressions) - - conditions = [] - for condition in parsed_query['condition'].values(): - conditions.append('`{}`="{}"'.format( - condition['key'], condition['value'] - )) - conditions = ' AND '.join(conditions) - - return {'expressions': expressions, 'conditions': conditions} -- cgit v1.2.3