from pathlib import Path


def _parse_dotenv(path: Path) -> dict:
    """
    Parse .env file into a simple dict

    """
    env = dict()

    with path.open() as file:
        for iline, line in enumerate(file):
            line = line.strip()
            if '=' not in line:
                raise ValueError("line {} [line #{}] in {} is missing "
                                 "a key value pair".format(line, iline, path))
            key, value = line.split('=', 1)
            env[key] = value

    return env