Theshutil module offers a number of high-level operations onfiles and collections of files. In particular, functions are provided which support file copying and removal.
Caveat: On MacOS, the resource fork and other metadata arenot used. For file copies, this means that resources will be lost and file type and creator codes will not be correct.
The source code for this should be considered an example rather than a tool.
Ifonerror is provided, it must be a callable that accepts three parameters:function,path, andexcinfo. The first parameter,function, is the function which raised the exception; it will beos.remove() oros.rmdir(). The second parameter,path, will be the path name passed tofunction. The third parameter,excinfo, will be the exception information return bysys.exc_info(). Exceptions raised byonerror will not be caught.
| Python Library Reference |