Model/model_data/epc_attributes/LightingAttributes.py
2023-08-01 14:45:29 +01:00

40 lines
1.3 KiB
Python

import re
from model_data.epc_attributes.attribute_utils import clean_description
from model_data.utils import correct_spelling
class LightingAttributes:
def __init__(self, description, averages):
self.description: str = clean_description(description.lower())
self.description = correct_spelling(self.description)
self.averages = averages
def process(self):
description = self.description
if 'no low energy lighting' in description:
return {"low_energy_proportion": 0}
if "all fixed outlets" in description:
return {"low_energy_proportion": 1}
if ('good lighting efficiency' in description) or ('excellent lighting efficiency' in description) or \
('below average lighting efficiency' in description):
average = [
x for x in self.averages if x["lighting-description"] == description
][0]["low-energy-lighting"]
return {
"low_energy_proportion": average
}
match = re.search(r'\d+', description)
if match:
proportion = int(match.group()) / 100.0
return {
"low_energy_proportion": proportion
}
raise NotImplementedError("Not handled this case - investigate me")