1
from httpx import QueryParams
4
def clean_filter(qp: QueryParams | dict, _filter: str) -> list:
6
Отбирает параметры согласно фильтру
11
for k, v in qp.items():
12
if not k.startswith(_filter):
16
filterred_key = k.replace(_filter, '')
17
model, line_number, field_name = filterred_key.split('--')[:3]
18
if len(filterred_key.split('--')) == 3:
19
if not models.get(model):
20
models.update({model: {line_number: {field_name: v}}})
22
if not models[model].get(line_number):
23
models[model].update({line_number: {field_name: v}})
25
models[model][line_number].update({field_name: v})
27
elif len(filterred_key.split('--')) == 5:
28
_model, _line_number, _field_name = filterred_key.split('--')[2:5]
29
if not models.get(model):
30
models.update({model: {line_number: {field_name: {_line_number: {_field_name: v}}}}})
32
if not models[model].get(line_number):
33
models[model].update({line_number: {field_name: {_line_number: {_field_name: v}}}})
35
if not models[model][line_number].get(field_name):
36
models[model][line_number].update({field_name: {_line_number: {_field_name: v}}})
38
if not models[model][line_number][field_name].get(_line_number):
39
models[model][line_number][field_name].update({_line_number: {_field_name: v}})
41
models[model][line_number][field_name][_line_number].update({_field_name: v})
46
for k, v in models.items():
47
for _k, _v in v.items():
48
models_cleaned.append(_v)
49
for __k, __v in _v.items():
50
if isinstance(__v, dict):
52
for ___k, ___v in __v.items():