# AUTOGENERATED! DO NOT EDIT! File to edit: ../../../pts/mod/cmds/02_get_repo_sync_status.pct.py.

# %% top_export
from pathlib import Path
from enum import Enum

from repoyard.config import get_config, StorageType
from repoyard._models import SyncStatus, RepoPart
from repoyard import const

async def get_repo_sync_status(
    config_path: Path,
    repo_full_name: str,
) -> dict[RepoPart, SyncStatus]:
    """
    """
    
    # AUTOGENERATED! DO NOT EDIT! File to edit: ../../../pts/mod/cmds/02_get_repo_sync_status.pct.py.
    
    # %% auto 0
    __all__ = ['config', 'repoyard_meta', 'repo_meta', 'tasks', 'repo_sync_status']
    
    # %% ../../../pts/mod/cmds/02_get_repo_sync_status.pct.py 12
    config = get_config(config_path)
    
    # %% ../../../pts/mod/cmds/02_get_repo_sync_status.pct.py 15
    from .._models import get_repoyard_meta
    repoyard_meta = get_repoyard_meta(config)
    
    if repo_full_name not in repoyard_meta.by_full_name:
        raise ValueError(f"Repo '{repo_full_name}' not found.")
    
    repo_meta = repoyard_meta.by_full_name[repo_full_name]
    
    # %% ../../../pts/mod/cmds/02_get_repo_sync_status.pct.py 16
    from .._models import get_sync_status, RepoPart
    import asyncio
    
    tasks = [get_sync_status(
        rclone_config_path=config.rclone_config_path,
        local_path=repo_meta.get_local_repometa_path(config),
        local_sync_record_path=repo_meta.get_local_sync_record_path(config, repo_part),
        remote=repo_meta.storage_location,
        remote_path=repo_meta.get_remote_repometa_path(config),
        remote_sync_record_path=repo_meta.get_remote_sync_record_path(config, repo_part),
    ) for repo_part in RepoPart]
    
    repo_sync_status = {repo_part : sync_status for repo_part, sync_status in zip(RepoPart, await asyncio.gather(*tasks))}
    return repo_sync_status;