projects
/
python_utils.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add another profanity.
[python_utils.git]
/
site_config.py
diff --git
a/site_config.py
b/site_config.py
index 3bf049e3787f66a38f42b5be0330642f4f39e645..fcf22a8d2cf20d4e6a6dd83690a51de08ce2f44d 100644
(file)
--- a/
site_config.py
+++ b/
site_config.py
@@
-71,6
+71,14
@@
def is_anyone_present_wrapper(location: Location):
def other_location() -> str:
def other_location() -> str:
+ """
+ Returns the location where this program is _NOT_ running.
+
+ >>> x = other_location()
+ >>> x in set(['HOUSE', 'CABIN'])
+ True
+
+ """
hostname = platform.node()
if '.house' in hostname:
location = 'CABIN'
hostname = platform.node()
if '.house' in hostname:
location = 'CABIN'
@@
-82,6
+90,14
@@
def other_location() -> str:
def this_location() -> str:
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'
hostname = platform.node()
if '.house' in hostname:
location = 'HOUSE'
@@
-92,15
+108,17
@@
def this_location() -> str:
return location
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.
+def effective_location(location_override: Optional[str] = None) -> str:
+ """Detects and returns a location taking into account two override
+ mechanisms.
- >>>
cfg = get_config
()
- >>>
cfg.location_name == 'HOUSE' or cfg.location_name == 'CABIN'
+ >>>
x = effective_location
()
+ >>>
x in set(['HOUSE', 'CABIN'])
True
True
+ >>> effective_location('HOUSE')
+ 'HOUSE'
+
"""
if location_override is None:
try:
"""
if location_override is None:
try:
@@
-111,8
+129,22
@@
def get_config(location_override: Optional[str] = None):
if location_override is None or location_override == 'NONE':
location = this_location()
else:
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
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)
if location == 'HOUSE':
return SiteConfig(
location_name='HOUSE',
if location == 'HOUSE':
return SiteConfig(
location_name='HOUSE',