def bool( env_var: builtins.str, default: Optional[builtins.bool] = None, ) -> Optional[builtins.bool]: """ Parse environment variable value into a boolean. Args: env_var (str): Name of desired environment variable. default (bool, optional): Optional fallback value. Returns: bool (optional): Environment variable typecast into a boolean. """ if env_var.lower() in TRUES: return True if env_var.lower() in FALSES: return False raise ValueError( f"Invalid boolean value specified: {env_var} " "Parsenvy accepts 'true', '1', 'false', and '0' as boolean values." )
def __call__(self, string: builtins.str) -> pathlib.Path: if not string.endswith(".csv") or not string.isprintable(): msg = (f"{string} is not a valid path to a csv file.\n" "file needs to end with csv and only contain " "printable characters.") raise argparse.ArgumentTypeError(msg) path = pathlib.Path(string) return path
def set( env_var: builtins.str, default: Optional[Set[Any]] = None, ) -> Optional[Set[Any]]: if env_var is None or env_var == "": return default return builtins.set(env_var.split(","))
def tuple( env_var: builtins.str, default: Optional[Tuple[Any, ...]] = None, ) -> Optional[Tuple[Any, ...]]: if env_var == "": return default return builtins.tuple(env_var.split(","))
def list( env_var: builtins.str, default: Optional[List[Any]] = None, ) -> Optional[List[Any]]: if env_var == "": return default return env_var.split(",")
def list( env_var: builtins.str, default: Optional[List[Any]] = None, ) -> Optional[List[Any]]: """ Parse environment variable value into a list. Args: env_var (str): Name of desired environment variable. default (List, optional): Optional fallback value. Returns: List (optional): Environment variable typecast into a list. """ if env_var == "": return default return env_var.split(",")
def tuple( env_var: builtins.str, default: Optional[Tuple[Any, ...]] = None, ) -> Optional[Tuple[Any, ...]]: """ Parse environment variable value into a tuple. Args: env_var (str): Name of desired environment variable. default (tuple, optional): Optional fallback value. Returns: tuple (optional): Environment variable typecast into a tuple. """ if env_var == "": return default return builtins.tuple(env_var.split(","))