diff --git a/src/python/jw/pkg/lib/CopyContext.py b/src/python/jw/pkg/lib/CopyContext.py index 3690d7b7..649a9614 100644 --- a/src/python/jw/pkg/lib/CopyContext.py +++ b/src/python/jw/pkg/lib/CopyContext.py @@ -1,8 +1,13 @@ -from typing import Any, Self +from __future__ import annotations + +from typing import TYPE_CHECKING, Any, Self from .FileContext import FileContext from .Uri import Uri +if TYPE_CHECKING: + from .PathFilter import PathFilter + class CopyContext: def __init__( @@ -10,6 +15,7 @@ class CopyContext: src: Uri | str | FileContext, dst: Uri | str | FileContext, chroot: bool = False, + default_path_filter: str | PathFilter | None = None, ) -> None: def __uri(ctx: FileContext | Uri | str) -> Uri | str: @@ -29,17 +35,26 @@ class CopyContext: self.__src, self.__src_uri = __info(src) self.__dst, self.__dst_uri = __info(dst) self.__chroot = chroot + self.__default_path_filter = default_path_filter async def __aenter__(self) -> Self: if self.__src is None: if self.__src_uri is None: raise Exception('Tried to create source context without URI') - self.__src = FileContext.create(self.__src_uri, chroot = self.__chroot) + self.__src = FileContext.create( + self.__src_uri, + chroot = self.__chroot, + default_path_filter = self.__default_path_filter, + ) await self.__src.open() if self.__dst is None: if self.__dst_uri is None: raise Exception('Tried to create destination context without URI') - self.__dst = FileContext.create(self.__dst_uri, chroot = self.__chroot) + self.__dst = FileContext.create( + self.__dst_uri, + chroot = self.__chroot, + default_path_filter = self.__default_path_filter, + ) await self.__dst.open() return self