lib.util.copy(): Move closure __copy_tree() to top #164

Merged
Jan Lindemann merged 1 commit from jan/fix/20261102-lib-util-copy-move-closure-copy-tree-to-top into master 2026-11-02 16:52:35 +01:00 AGit

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