diff options
| author | Andrew <saintruler@gmail.com> | 2019-07-07 15:40:51 +0400 |
|---|---|---|
| committer | Andrew <saintruler@gmail.com> | 2019-07-07 15:40:51 +0400 |
| commit | f41cd316889dcbdc62e22e6622a6ecea4a435084 (patch) | |
| tree | 7a3126c2db94ba669b046777ad3cefecb9955a2d /day9/task5/utils.py | |
| parent | 8ebc8b62e647353756288a77f2d17774ef78634c (diff) | |
WIP: Добавлено изменение отдельных полей в таблице.
Diffstat (limited to 'day9/task5/utils.py')
| -rw-r--r-- | day9/task5/utils.py | 31 |
1 files changed, 0 insertions, 31 deletions
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} |