Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Add ignore keyword argument to copytree (#272) * Add `ignore` keyword argument to `copytree` The `ignore` argument expects a callable that returns a list of names that will be ignored while copying. It supports `shutil.ignore_patterns` [1] to allow using a similar interface. Also, include proper typing according to the behaviour described in the Python docs on `shutil.copytree` and expanding it to support the `cloudpathlib` environment. [1]: https://docs.python.org/3/library/shutil.html#shutil.ignore_patterns Signed-off-by: Antonio Ossa Guerra <aaossa@uc.cl> * Add tests for `ignore` argument on `copytree` When the argument is not used (defaults to `None`), the function should work normally. The arguments is expected to be a callable that, given a list of names, returns a list of ignored names to skip those names while performing the copy. The tests create additional files in the reference path (`p`): a Python file (`ignored.py`) and two directories (`dir1/` and `dir2/`). These files are ignored in two different ways, and tested separatelly: using `shutil.ignore_patterns` and using a custom ignore function The tests are performed by copying the tree (and ignoring the files) and then comparing the source and destination (checking that every file in the destination is also in the source), and asserting that the ignored files do not exist in the destination. Signed-off-by: Antonio Ossa Guerra <aaossa@uc.cl> Signed-off-by: Antonio Ossa Guerra <aaossa@uc.cl> * Update changelog and version Signed-off-by: Antonio Ossa Guerra <aaossa@uc.cl> Co-authored-by: Antonio Ossa-Guerra <aaossa@uc.cl>
- Loading branch information