def load_env_from_file(filename):
    """
    Read an env file into a collection of (name, value) tuples.
    """
    if not os.path.exists(filename):
        raise FileNotFoundError("Environment file {} does not exist.".format(filename))

    with open(filename) as f:
        for lineno, line in enumerate(f):
            line = line.strip()
            if not line or line.startswith("#"):
                continue
            if "=" not in line:
                raise SyntaxError("Invalid environment file syntax in {} at line {}.".format(filename, lineno + 1))

            name, value = parse_var(line)

            yield name, value
Read an env file into a collection of (name, value) tuples.