import hashlib
from pathlib import Path


def repo_url_hash_path_builder(working_directory, url):
    """Returns a unique repo Path in the given working_directory based on a
    two level hash of the repo URL.
    """
    url_hash = hashlib.md5(url.encode("utf-8")).hexdigest()
    parent_directory = url_hash[:2]
    repository_directory = url_hash[2:]
    return Path(working_directory)\
        .joinpath(parent_directory)\
        .joinpath(repository_directory)