25 lines
892 B
Python
25 lines
892 B
Python
VALUES = ['low', 'mid', 'high']
|
|
|
|
|
|
def production_year_to_value(production_year):
|
|
return VALUES[["Dawno", "Średnio", "Niedawno"].index(production_year)]
|
|
|
|
def mileage_to_value(mileage):
|
|
return VALUES[["Niski", "Średni", "Duży"].index(mileage)]
|
|
|
|
def engine_capacity_to_value(engine_capacity):
|
|
return VALUES[["Mała", "Średnia", "Ogromna"].index(engine_capacity)]
|
|
|
|
def combustion_to_value(combustion):
|
|
return VALUES[["Niskie", "Średnie", "Wysokie"].index(combustion)]
|
|
|
|
|
|
def map_query_params(query_params):
|
|
values = {}
|
|
params = ['production_year', 'mileage', 'engine_capacity', 'combustion']
|
|
funcs = [production_year_to_value, mileage_to_value, engine_capacity_to_value, combustion_to_value]
|
|
for param, func in zip(params, funcs):
|
|
if (query_param := query_params.get(param)):
|
|
values[param] = func(query_param)
|
|
return values
|
|
|