[PR jw/#164] lib.util.copy(): Move closure __copy_tree() to top
All checks were successful
CI / Packaging - Kali Linux (push) Successful in 4m32s
CI / Packaging - OpenSUSE Tumbleweed (push) Successful in 4m49s
CI / Packaging test (push) Successful in 0s

Merge pull request "lib.util.copy(): Move closure __copy_tree() to top"

Upstream-repo: ssh://git@code.janware.com/janware/jw-pkg
Source-branch: jan/fix/20261102-lib-util-copy-move-closure-copy-tree-to-top
Target-branch: master
Reviewed-on: #164
This commit is contained in:
Jan Lindemann 2026-11-02 16:52:35 +01:00 • committed by janware Code
commit 28c4b00db2
Signed by: Code Bot
GPG key ID: 66A5D2B295EE1224

View file

@ -179,22 +179,6 @@ async def copy(
parents: bool = False,
) -> Exception | str | list[str]:
# Destination address / addresses
ret: str | list[str]
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)
if isinstance(rr, Exception):
return rr
if isinstance(rr, list):
ret.extend(rr)
if isinstance(rr, str):
ret.append(rr)
else:
raise Exception(f'copy() returned unexpected type {type(rr)}')
return ret
async def __copy_tree(src_path: str, dst_path: str) -> list[str]:
ret: list[str] = []
s_st = await ctx.src.stat(src_path)
@ -222,6 +206,22 @@ async def copy(
ret.append(d_path)
return ret
# Destination address / addresses
ret: str | list[str]
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)
if isinstance(rr, Exception):
return rr
if isinstance(rr, list):
ret.extend(rr)
if isinstance(rr, str):
ret.append(rr)
else:
raise Exception(f'copy() returned unexpected type {type(rr)}')
return ret
try:
from .CopyContext import CopyContext