pathlib-abc
pathlib-abc copied to clipboard
Support for copy filters
It should be possible to implement copying filters similar to tarfile extraction filters: https://docs.python.org/3/library/tarfile.html#extraction-filters
My current thinking:
- absolute paths: handle via the
.joinpath('_').with_name(name)idiom - symlink targets: the
ReadablePath.copy()implementation should error out if a symlink target has a non-empty anchor or..segment. ThePath.copy()implementation would skip these checks if the target is local. - metadata: we add an info argument to
__open_writer__(),mkdir()andsymlink_to(). Inpathlib.Path, we'd check whetherisinstance(info, _LocalPathInfo). If it is, we fully trust the giveninfoobject and call some private methods. If it isn't, we copy only the permissions (subject to filtering) and access/modify times.