import sys
from typing import Any, Dict, List, Optional, Tuple
-import scott_secrets
-
# This module is commonly used by others in here and should avoid
# taking any unnecessary dependencies back on them.
env = env[1:]
return var, env, chunks
+ @staticmethod
+ def _to_bool(in_str: str) -> bool:
+ """
+ Args:
+ in_str: the string to convert to boolean
+
+ Returns:
+ A boolean equivalent of the original string based on its contents.
+ All conversion is case insensitive. A positive boolean (True) is
+ returned if the string value is any of the following:
+
+ * "true"
+ * "t"
+ * "1"
+ * "yes"
+ * "y"
+ * "on"
+
+ Otherwise False is returned.
+
+ >>> to_bool('True')
+ True
+
+ >>> to_bool('1')
+ True
+
+ >>> to_bool('yes')
+ True
+
+ >>> to_bool('no')
+ False
+
+ >>> to_bool('huh?')
+ False
+
+ >>> to_bool('on')
+ True
+ """
+ return in_str.lower() in ("true", "1", "yes", "y", "t", "on")
+
def _augment_sys_argv_from_environment_variables(self):
"""Internal. Look at the system environment for variables that match
commandline arg names. This is done via some munging such that:
self.saved_messages.append(
f'Initialized from environment: {var} = {value}'
)
- from string_utils import to_bool
-
- if len(chunks) == 1 and to_bool(value):
+ if len(chunks) == 1 and Config._to_bool(value):
sys.argv.append(var)
elif len(chunks) > 1:
sys.argv.append(var)
if loadfile[:3] == 'zk:':
from kazoo.client import KazooClient
+ import scott_secrets
+
try:
if self.zk is None:
+
self.zk = KazooClient(
hosts=scott_secrets.ZOOKEEPER_NODES,
use_ssl=True,
if not self.zk:
from kazoo.client import KazooClient
+ import scott_secrets
+
self.zk = KazooClient(
hosts=scott_secrets.ZOOKEEPER_NODES,
use_ssl=True,