lib.util.copy(): Move closure __copy_tree() to top #164
1 changed files with 16 additions and 16 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue