Skip to content

Commit

Permalink
removed tkl_dict_to_bs_dict
Browse files Browse the repository at this point in the history
  • Loading branch information
YaokunLin committed Oct 5, 2023
1 parent 138e45d commit 63016d9
Show file tree
Hide file tree
Showing 2 changed files with 7,602 additions and 2,427 deletions.
32 changes: 16 additions & 16 deletions api/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,22 +199,22 @@ def tkl_to_bs(sensor: TekelekSensor) -> BasicSensor:


# 🔧 Function to convert TeklekSensor dictionary to BasicSensor dictionary
def tkl_dict_to_bs_dict(sensors: List[Dict[str, Union[str, int, float, None]]]) -> dict:
bs_dict = {}
# loop to iterate through each obj in the TekelekSensor list
for sensor_data in sensors:
try:
# create a TekelekSensor object (sensor_obj) by passing the dictionary sensor_data as keyword argument
sensor_obj = TekelekSensor(**sensor_data)

# print(f"sensor_obj : {sensor_obj }")
# convert the TekelekSensor into a BasicSensor and store it in the bs_dict dictionary.
bs_dict[sensor_obj.ModemSerialNo] = tkl_to_bs(sensor_obj)
except (ValueError, KeyError, TypeError) as e:
print(f"Error processing sensor {sensor_obj.ModemSerialNo}: {e}")
# Optionally, continue to the next iteration
continue
return bs_dict
# def tkl_dict_to_bs_dict(sensors: List[Dict[str, Union[str, int, float, None]]]) -> dict:
# bs_dict = {}
# # loop to iterate through each obj in the TekelekSensor list
# for sensor_data in sensors:
# try:
# # create a TekelekSensor object (sensor_obj) by passing the dictionary sensor_data as keyword argument
# sensor_obj = TekelekSensor(**sensor_data)

# # print(f"sensor_obj : {sensor_obj }")
# # convert the TekelekSensor into a BasicSensor and store it in the bs_dict dictionary.
# bs_dict[sensor_obj.ModemSerialNo] = tkl_to_bs(sensor_obj)
# except (ValueError, KeyError, TypeError) as e:
# print(f"Error processing sensor {sensor_obj.ModemSerialNo}: {e}")
# # Optionally, continue to the next iteration
# continue
# return bs_dict


# 🔧 Function to convert BrighterBinsSensor to BasicSensor with latest reading
Expand Down
Loading

0 comments on commit 63016d9

Please sign in to comment.