Skip to content

Commit

Permalink
Try 3
Browse files Browse the repository at this point in the history
  • Loading branch information
bouwew committed Jan 30, 2025
1 parent 1028f17 commit be8db47
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion plugwise/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,13 +216,19 @@ def format_measure(measure: str, unit: str) -> float | int:
def get_vendor_name(module: etree, model_data: ModuleData) -> ModuleData:
"""Helper-function for _get_model_data()."""
if (vendor_name := module.find("vendor_name").text) is not None:
model_data["vendor_name"] = vendor_name.decode("utf-8")
model_data["vendor_name"] = parse_escapes(vendor_name)
if "Plugwise" in vendor_name:
model_data["vendor_name"] = vendor_name.split(" ", 1)[0]

return model_data


def parse_escapes(text):
"""Helper-function for get_vendor_name()."""
fixed_escapes = re.sub(r'(?<!\\)(\\\\)*("|\\$)', r'\\\1\2', text)
return ast.literal_eval(f'"{fixed_escapes}"')


def power_data_energy_diff(
measurement: str,
net_string: SensorType,
Expand Down

0 comments on commit be8db47

Please sign in to comment.