import pathlib
from typing import List


def _get_pkgfiles_and_dirs_at_path(path: pathlib.Path) -> tuple:
    """Utility function to get the tar.gz files and the directories
    at a given URL.
    """
    packages: List[pathlib.Path] = []
    dirs: List[pathlib.Path] = []

    if not path.exists():
        return packages, dirs

    for entry in path.iterdir():
        if entry.name == "PACKAGES.gz":
            continue
        elif entry.suffix.endswith("gz"):
            packages.append(entry)
        elif entry.is_dir():
            dirs.append(entry)

    return packages, dirs