+def this_location() -> str:
+ """
+ Returns the location where this program _IS_ running.
+
+ >>> x = this_location()
+ >>> x in set(['HOUSE', 'CABIN'])
+ True
+
+ """
+ hostname = platform.node()
+ if '.house' in hostname:
+ location = 'HOUSE'
+ elif '.cabin' in hostname:
+ location = 'CABIN'
+ else:
+ raise Exception(f"{hostname} doesn't help me know where I'm running?!")
+ return location
+
+
+def effective_location(location_override: Optional[str] = None) -> str:
+ """Detects and returns a location taking into account two override
+ mechanisms.
+
+ >>> x = effective_location()
+ >>> x in set(['HOUSE', 'CABIN'])
+ True
+
+ >>> effective_location('HOUSE')
+ 'HOUSE'
+
+ """
+ if location_override is None:
+ try:
+ location_override = config.config['site_config_override_location']
+ except KeyError:
+ location_override = None
+
+ 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}')
+ location = location_override
+ return location
+
+
+def get_config(location_override: Optional[str] = None):
+ """
+ Get a configuration dataclass with information that is
+ site-specific including the current running location.
+
+ >>> cfg = get_config()
+ >>> cfg.location_name == 'HOUSE' or cfg.location_name == 'CABIN'
+ True
+
+ """
+ location = effective_location(location_override)