# -*- coding: utf-8 -*- from typing import Self from .FileContext import FileContext class CopyContext: def __init__(self, src_uri: str, dst_uri: str, chroot=False) -> None: self.__src_uri = src_uri self.__dst_uri = dst_uri self.__chroot = chroot async def __aenter__(self) -> Self: self.__src = FileContext.create(self.__src_uri, chroot=self.__chroot) await self.__src.open() self.__dst = FileContext.create(self.__dst_uri, chroot=self.__chroot) await self.__dst.open() return self async def __aexit__(self, exc_type, exc, tb): if self.__src is not None: await self.__src.close() self.__src = None if self.__dst is not None: await self.__dst.close() self.__dst = None @property def src(self) -> FileContext: return self.__src @property def dst(self) -> FileContext: return self.__dst async def _run(self) -> None: await self._run() async def run(self) -> None: await self._run()