For the following code I would like to use a structure in order to not have to give 2 values for each element min and max and also I would like to have a container if exists to can give one value and the other one to remain None. For instance power to have only min element. So for power to have a container with 2 elements (for min and max) and same for temperature. How is that possible in python ? please help, thanks!
def result_final(
power_min,
power_max,
temperature_min,
temperature_max
) -> str:
def _result_min(value) -> str:
return "<min>" "<value>" + str(value) + "</value>" + "</min>"
def _result_max(value) -> str:
return "<max>" "<value>" + str(value) + "</value>" +" </max>"
def _measure_result(unit_id, min_value, max_value) -> str:
return (
"<measure_result>"
"<unit-id>" + str(unit_id) + "</unit-id>"
"" + _result_min(min_value) + ""
"" + _result_max(max_value) + ""
"</measure_result>"
)
def _stats(object, min_value, max_value) -> str:
return (
"<stats>"
"<object>" + object + "</object>"
"" + _measure_result(0, min_value, max_value) + ""
"" + _measure_result(1, min_value, max_value) + ""
"</stats>"
)
content = (
'<result-stats>'
"" + _stats("POWER", power_min, power_max) + ""
"" + _stats("TEMPERATURE", temperature_min, temperature_max) + ""
"</result-stats>"
)
return content
x = result_final(power_min = 12, power_max = 125, temperature_min = 12, temperature_max = 12)
print(x)