Model/model_data/epc_attributes/LightingAttributes.py
2023-07-03 15:07:36 +01:00

29 lines
924 B
Python

import re
from model_data.epc_attributes.attribute_utils import clean_description
class LightingAttributes:
def __init__(self, description, averages):
self.description: str = clean_description(description.lower())
self.averages = averages
def low_energy_proportions(self):
description = self.description
if 'no low energy lighting' in description:
return 0
if "all fixed outlets" in description:
return 1
if ('good lighting efficiency' in description) or ('excellent lighting efficiency' in description) or \
('below average lighting efficiency' in description):
return self.averages[self.averages == description]["low-energy-lighting"].values[0]
match = re.search(r'\d+', description)
if match:
proportion = int(match.group()) / 100.0
return proportion
return 0