[Python-ideas] Add shutil.ignore_patterns() to shutil.rmtree()

George Fischhof george at fischhof.hu
Fri May 5 06:46:54 EDT 2017


2017-05-05 11:52 GMT+02:00 Serhiy Storchaka <storchaka at gmail.com>:

> On 05.05.17 10:58, George Fischhof wrote:
>
>> I have a task to synchronize folders but some files should be remained
>> untouched.
>> I think this is a very common task.
>>
>> I found that shutil.copytree() has ignore_patterns() but rmtree() has not.
>>
>> So here comes my idea: add ignore_patterns() to rmtree() it is a good
>> feature and makes the functions symmetric.
>>
>
> You can't remove a tree when remain its branches. Thus rmtree() with
> ignore_patterns will always fail.
>
> For your particular case I suggest to use os.walk(). You can implement
> arbitrary application specific conditions.
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>



If the remaining equals to ignore_pattern plus the container folders, then
it is succesful ;-) In my opinion
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20170505/f8dff71d/attachment.html>


More information about the Python-ideas mailing list