#!/usr/bin/env python3
+# © Copyright 2021-2022, Scott Gasch
+
+"""Location/site dependent data."""
+
import logging
import platform
from dataclasses import dataclass
@dataclass
class SiteConfig(object):
+ """The set of information specific to where the program is running."""
+
location_name: str
location: Location
network: str
>>> x in set(['HOUSE', 'CABIN'])
True
+ >>> y = this_location()
+ >>> x == y
+ False
+
"""
- hostname = platform.node()
- if '.house' in hostname:
- location = 'CABIN'
- elif '.cabin' in hostname:
- location = 'HOUSE'
+ this = this_location()
+ if this == 'HOUSE':
+ return 'CABIN'
+ elif this == 'CABIN':
+ return 'HOUSE'
else:
- raise Exception(f"{hostname} doesn't help me know where I'm running?!")
- return location
+ raise Exception(f"{this} doesn't tell me where I'm running?!")
def this_location() -> str:
location = 'HOUSE'
elif '.cabin' in hostname:
location = 'CABIN'
+ elif '.local' in hostname:
+ location = 'HOUSE'
else:
raise Exception(f"{hostname} doesn't help me know where I'm running?!")
return location
if location_override is None or location_override == 'NONE':
location = this_location()
else:
- logger.debug(f'site_config\'s location_override was set to: {location_override}')
+ logger.debug('site_config\'s location_override was set to: %s', location_override)
location = location_override
return location