lib.util.copy(): Add optional default_path_filter
Hand the new default_path_filter parameter to the CopyContext copy() opens, and to the recursive calls it makes for a list of URIs, so an app can limit the addresses a copy touches the same way it limits its own contexts. Signed-off-by: Jan Lindemann <jan@janware.com> Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v1.5.0
This commit is contained in:
parent
4117143c05
commit
d27bf01714
1 changed files with 15 additions and 2 deletions
|
|
@ -16,6 +16,7 @@ if TYPE_CHECKING:
|
|||
from argparse import Namespace
|
||||
|
||||
from .ExecContext import ExecContext
|
||||
from .PathFilter import PathFilter
|
||||
from .ProcFilter import ProcFilter, ProcPipeline
|
||||
|
||||
T = TypeVar('T')
|
||||
|
|
@ -177,6 +178,7 @@ async def copy(
|
|||
throw: bool = True,
|
||||
recursive: bool = False,
|
||||
parents: bool = False,
|
||||
default_path_filter: str | PathFilter | None = None,
|
||||
) -> Exception | str | list[str]:
|
||||
|
||||
async def __copy_tree(src_path: str, dst_path: str) -> list[str]:
|
||||
|
|
@ -211,7 +213,17 @@ async def copy(
|
|||
if not isinstance(src, (str, FileContext)):
|
||||
ret = []
|
||||
for uri in src: # TODO: Group identical netlocs into one CopyContext
|
||||
rr = await copy(uri, dst, owner, group, mode, throw, recursive, parents)
|
||||
rr = await copy(
|
||||
uri,
|
||||
dst,
|
||||
owner,
|
||||
group,
|
||||
mode,
|
||||
throw,
|
||||
recursive,
|
||||
parents,
|
||||
default_path_filter,
|
||||
)
|
||||
if isinstance(rr, Exception):
|
||||
return rr
|
||||
if isinstance(rr, list):
|
||||
|
|
@ -226,7 +238,8 @@ async def copy(
|
|||
|
||||
from .CopyContext import CopyContext
|
||||
|
||||
async with CopyContext(src, dst) as ctx:
|
||||
async with CopyContext(src, dst,
|
||||
default_path_filter = default_path_filter) as ctx:
|
||||
|
||||
src_uri = src.uri if isinstance(src, FileContext) else Uri(src)
|
||||
ret = '' if ctx.dst.chroot else ctx.dst.root
|
||||
|
|
|
|||
Loading…
Reference in a new issue