It will be very useful to have a support for the Pathlib acts like input parameters for methods. E.g. you can do something like ftp_host.chdir(Path("/my/dir/"))
Generally, this sounds like a sensible idea. However, according to the documentation at https://docs.python.org/3/library/pathlib.html ,
Path(...)instantiates a filesystem path for the operating system the Python process runs on.
A path object to be used as an FTP remote path should probably be an
FTPPath(or something with a similar name). I'm not sure yet how to implement this. From a pure implementation perspective, an
FTPPathcould be aliased to a
PurePosixPath, but having
isinstance(FTPPath(...), PurePosixPath)evaluate to
Truewould be confusing. Although most FTP servers will run on a Posix system, an
FTPPathshouldn't assume this. Also, some
PurePosixPathoperations may not make sense for a remote filesystem.
Since Python 3.6 there's
os.PathLike. I think that's what a custom path class should inherit from.
tool.as_strand let it accept
FTPPathclass with the following attributes and methods:
parts drive root anchor parents parent name suffix suffixes stem
__truediv__ as_posix as_uri is_absolute is_reserved joinpath match relative_to with_name with_suffix
cwd home stat chmod exists expanduser glob group is_dir is_file is_mount is_symlink is_socket is_fifo is_block_device is_char_device iterdir lchmod lstat mkdir open owner read_bytes read_text rename replace resolve rglob rmdir samefile stat symlink_to touch unlink link_to write_bytes write_text
I assume the attributes and
PurePathmethods can be implemented by delegating to an internal
As of a2267f4e11fd2acbd83b3e58c03963ff896cc4d2, methods that used to accept "only"
strobjects now also accept
PathLikeobjects that can be converted to
str. Actually, this is the functionality the description asked for.
FTPPathclass as described above is much more effort.
I changed the title to let it reflect the ticket description. If support for a custom
FTPPathis requested, this should better go into a new ticket.