system_assignation/imports/usage/helpers/usage_helper.py

88 lines
2.5 KiB
Python

"""
Usage helper
SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2020 Project Author Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
"""
import sys
import helpers.constants as cte
class UsageHelper:
"""
Usage helper class
"""
_usage_to_hft = {
cte.RESIDENTIAL: 'residential',
cte.INDUSTRY: 'industry',
cte.OFFICE_ADMINISTRATION: 'office and administration',
cte.HOTEL: 'hotel',
cte.HEALTH_CARE: 'health care',
cte.RETAIL: 'retail',
cte.HALL: 'hall',
cte.RESTAURANT: 'restaurant',
cte.EDUCATION: 'education'}
@staticmethod
def hft_from_usage(usage):
"""
Get HfT usage from the given internal usage key
:param usage: str
:return: str
"""
try:
return UsageHelper._usage_to_hft[usage]
except KeyError:
sys.stderr.write('Error: keyword not found.\n')
_usage_to_comnet = {
cte.RESIDENTIAL: 'BA Multifamily',
cte.INDUSTRY: 'BA Manufacturing Facility',
cte.OFFICE_ADMINISTRATION: 'BA Office',
cte.HOTEL: 'BA Hotel',
cte.HEALTH_CARE: 'BA Hospital',
cte.RETAIL: 'BA Retail',
cte.HALL: 'BA Town Hall',
cte.RESTAURANT: 'BA Dining: Bar Lounge/Leisure',
cte.EDUCATION: 'BA School/University'}
_comnet_schedules_key_to_comnet_schedules = {
'C-1 Assembly': 'C-1 Assembly',
'C-2 Public': 'C-2 Health',
'C-3 Hotel Motel': 'C-3 Hotel',
'C-4 Manufacturing': 'C-4 Manufacturing',
'C-5 Office': 'C-5 Office',
'C-6 Parking Garage': 'C-6 Parking',
'C-7 Restaurant': 'C-7 Restaurant',
'C-8 Retail': 'C-8 Retail',
'C-9 Schools': 'C-9 School',
'C-10 Warehouse': 'C-10 Warehouse',
'C-11 Laboratory': 'C-11 Lab',
'C-12 Residential': 'C-12 Residential',
'C-13 Data Center': 'C-13 Data',
'C-14 Gymnasium': 'C-14 Gymnasium'}
@staticmethod
def comnet_from_usage(usage):
"""
Get Comnet usage from the given internal usage key
:param usage: str
:return: str
"""
try:
return UsageHelper._usage_to_comnet[usage]
except KeyError:
sys.stderr.write('Error: keyword not found.\n')
@staticmethod
def schedules_key(usage):
"""
Get Comnet schedules key from the list found in the Comnet usage file
:param usage: str
:return: str
"""
try:
return UsageHelper._comnet_schedules_key_to_comnet_schedules[usage]
except KeyError:
sys.stderr.write('Error: Comnet keyword not found. An update of the Comnet files might have been '
'done changing the keywords.\n')