Python shutil.html() Examples

The following are 4 code examples for showing how to use shutil.html(). These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.

You may check out the related API usage on the sidebar.

You may also want to check out all available functions/classes of the module shutil , or try the search function .

Example 1
Project: Dallinger   Author: Dallinger   File:    License: MIT License 6 votes vote down vote up
def exclusion_policy():
    """Returns a callable which, when passed a directory path and a list
    of files in that directory, will return a subset of the files which should
    be excluded from a copy or some other action.

    patterns = set(

    return shutil.ignore_patterns(*patterns) 
Example 2
Project: signac   Author: glotzerlab   File:    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def copytree(src, dst, copy_function=shutil.copy2, symlinks=False):
    "Implementation adapted from'."
    names = os.listdir(src)
    errors = []
    for name in names:
        srcname = os.path.join(src, name)
        dstname = os.path.join(dst, name)
            if symlinks and os.path.islink(srcname):
                linkto = os.readlink(srcname)
                os.symlink(linkto, dstname)
            elif os.path.isdir(srcname):
                copytree(srcname, dstname, copy_function, symlinks)
                copy_function(srcname, dstname)
        except OSError as why:
            errors.append((srcname, dstname, str(why)))
        # catch the Error from the recursive copytree so that we can
        # continue with other files
        except shutil.Error as err:
    if errors:
        raise shutil.Error(errors) 
Example 3
Project: penelope   Author: pettarin   File:    License: MIT License 6 votes vote down vote up
def delete_directory(path):
    Safely delete a directory.

    :param path: the file path
    :type  path: string (path)
    def remove_readonly(func, path, _):
        Clear the readonly bit and reattempt the removal

        Adapted from

        See also
            os.chmod(path, stat.S_IWRITE)
    if path is not None:
        shutil.rmtree(path, onerror=remove_readonly) 
Example 4
Project: ctc-asr   Author: mdangschat   File:    License: MIT License 6 votes vote down vote up
def delete_directory_if_exists(path):
    """Recursive delete of a folder and all contained files.

        path (str):  Directory path.


    if os.path.exists(path) and os.path.isdir(path):
        # Doesn't state which errors are possible.
        except OSError as exception:
            raise exception