Delete a directory or file at `location` recursively. Similar to "rm -rf" in a shell or a combo of os.remove and shutil.rmtree. This function is design to never fails: instead it logs warnings if the file or directory was not deleted correctly.
(location, _err_handler=_rm_handler)
| 562 | |
| 563 | |
| 564 | def delete(location, _err_handler=_rm_handler): |
| 565 | """ |
| 566 | Delete a directory or file at `location` recursively. Similar to "rm -rf" |
| 567 | in a shell or a combo of os.remove and shutil.rmtree. |
| 568 | This function is design to never fails: instead it logs warnings if the |
| 569 | file or directory was not deleted correctly. |
| 570 | """ |
| 571 | if not location: |
| 572 | return |
| 573 | |
| 574 | if os.path.exists(location) or filetype.is_broken_link(location): |
| 575 | if filetype.is_dir(location): |
| 576 | shutil.rmtree(location, False, _rm_handler) |
| 577 | else: |
| 578 | os.remove(location) |
no test coverage detected