sanic.utils.load_module_from_file_location#
Returns loaded module provided as a file path.
def load_module_from_file_location(location: typing.Union[bytes, str, pathlib.Path], encoding: <class 'str'> = utf8, args, kwargs)
Parameters
- args
Corresponds to importlib.util.spec_from_file_location location parameters,but with this differences:
- It has to be of a string or bytes type.
- You can also use here environment variables in format ${some_env_var}. Mark that $some_env_var will not be resolved as environment variable.
- args
Corresponds to the rest of importlib.util.spec_from_file_location parameters.
- kwargs
Corresponds to the rest of importlib.util.spec_from_file_location parameters.
For example You can:
some_module = load_module_from_file_location( "some_module_name", "/some/path/${some_env_var}" )
sanic.utils.str_to_bool#
Takes string and tries to turn it into bool as human would do.
def str_to_bool(val: <class 'str'>): -> <class 'bool'>
If val is in case insensitive ( "y", "yes", "yep", "yup", "t", "true", "on", "enable", "enabled", "1" ) returns True. If val is in case insensitive ( "n", "no", "f", "false", "off", "disable", "disabled", "0" ) returns False. Else Raise ValueError.