(dot_env_path: Text)
return env_variables_mapping
load .env file.

    Args:
        dot_env_path (str): .env file path

    Returns:
        dict: environment variables mapping

            {
                "UserName": "debugtalk",
                "Password": "123456",
                "PROJECT_KEY": "ABCDEFGH"
            }

    Raises:
        exceptions.FileFormatError: If .env file format is invalid.
load .env file.
load . env file .
def load_dot_env_file(dot_env_path: Text) -> Dict:
    """ load .env file.

    Args:
        dot_env_path (str): .env file path

    Returns:
        dict: environment variables mapping

            {
                "UserName": "debugtalk",
                "Password": "123456",
                "PROJECT_KEY": "ABCDEFGH"
            }

    Raises:
        exceptions.FileFormatError: If .env file format is invalid.

    """
    if not os.path.isfile(dot_env_path):
        return {}

    logger.info(f"Loading environment variables from {dot_env_path}")
    env_variables_mapping = {}

    with open(dot_env_path, mode="rb") as fp:
        for line in fp:
            # maxsplit=1
            if b"=" in line:
                variable, value = line.split(b"=", 1)
            elif b":" in line:
                variable, value = line.split(b":", 1)
            else:
                raise exceptions.FileFormatError(".env format error")

            env_variables_mapping[
                variable.strip().decode("utf-8")
            ] = value.strip().decode("utf-8")

    utils.set_os_environ(env_variables_mapping)
    return env_variables_mapping
def load_dot_env_file ( dot_env_path : Text ) -> Dict : if not os . path . isfile ( dot_env_path ) : return { } logger . info ( f"Loading environment variables from {dot_env_path}" ) env_variables_mapping = { } with open ( dot_env_path , mode = "rb" ) as fp : for line in fp : # maxsplit=1 if b"=" in line : variable , value = line . split ( b"=" , 1 ) elif b":" in line : variable , value = line . split ( b":" , 1 ) else : raise exceptions . FileFormatError ( ".env format error" ) env_variables_mapping [ variable . strip ( ) . decode ( "utf-8" ) ] = value . strip ( ) . decode ( "utf-8" ) utils . set_os_environ ( env_variables_mapping ) return env_variables_mapping