def get_subdirs(
    idp,
    base_name_only=False,
    sort_result=True,
    natural_sorting=False,
    recursive=False,
):
    """Return the paths of the subdirectories in the given directory."""
    if recursive:
        sub_dps = []
        if base_name_only:
            for root, dirs, files in os.walk(idp):
                sub_dps += [name for name in dirs]
        else:
            for root, dirs, files in os.walk(idp):
                sub_dps += [os.path.join(root, sub_dn) for sub_dn in dirs]
    else:
        sub_dns = [
            name
            for name in os.listdir(idp)
            if os.path.isdir(os.path.join(idp, name))
        ]
        if base_name_only:
            sub_dps = sub_dns
        else:
            sub_dps = [os.path.join(idp, sub_dn) for sub_dn in sub_dns]

    if sort_result:
        if natural_sorting:
            sub_dps = sorted(sub_dps, key=_natural_key)
        else:
            sub_dps = sorted(sub_dps)

    return sub_dps
Return the paths of the subdirectories in the given directory.
photogrammetry_importer/utility/os_utility.py