shutil.rmtree.avoids_symlink_attacks

rmtree.avoids_symlink_attacks Indicates whether the current platform and implementation provides a symlink attack resistant version of rmtree(). Currently this is only true for platforms supporting fd-based directory access functions. New in version 3.3.

shutil.rmtree()

shutil.rmtree(path, ignore_errors=False, onerror=None) Delete an entire directory tree; path must point to a directory (but not a symbolic link to a directory). If ignore_errors is true, errors resulting from failed removals will be ignored; if false or omitted, such errors are handled by calling a handler specified by onerror or, if that is omitted, they raise an exception. Note On platforms that support the necessary fd-based functions a symlink attack resistant version of rmtree() is use

shutil.register_unpack_format()

shutil.register_unpack_format(name, extensions, function[, extra_args[, description]]) Registers an unpack format. name is the name of the format and extensions is a list of extensions corresponding to the format, like .zip for Zip files. function is the callable that will be used to unpack archives. The callable will receive the path of the archive, followed by the directory the archive must be extracted to. When provided, extra_args is a sequence of (name, value) tuples that will be passed

shutil.register_archive_format()

shutil.register_archive_format(name, function[, extra_args[, description]]) Register an archiver for the format name. function is the callable that will be used to unpack archives. The callable will receive the base_name of the file to create, followed by the base_dir (which defaults to os.curdir) to start archiving from. Further arguments are passed as keyword arguments: owner, group, dry_run and logger (as passed in make_archive()). If given, extra_args is a sequence of (name, value) pairs

shutil.move()

shutil.move(src, dst, copy_function=copy2) Recursively move a file or directory (src) to another location (dst) and return the destination. If the destination is an existing directory, then src is moved inside that directory. If the destination already exists but is not a directory, it may be overwritten depending on os.rename() semantics. If the destination is on the current filesystem, then os.rename() is used. Otherwise, src is copied to dst using copy_function and then removed. In case o

shutil.make_archive()

shutil.make_archive(base_name, format[, root_dir[, base_dir[, verbose[, dry_run[, owner[, group[, logger]]]]]]]) Create an archive file (such as zip or tar) and return its name. base_name is the name of the file to create, including the path, minus any format-specific extension. format is the archive format: one of “zip”, “tar”, “bztar” (if the bz2 module is available), “xztar” (if the lzma module is available) or “gztar”. root_dir is a directory that will be the root directory of the archiv

shutil.ignore_patterns()

shutil.ignore_patterns(*patterns) This factory function creates a function that can be used as a callable for copytree()‘s ignore argument, ignoring files and directories that match one of the glob-style patterns provided. See the example below.

shutil.get_unpack_formats()

shutil.get_unpack_formats() Return a list of all registered formats for unpacking. Each element of the returned sequence is a tuple (name, extensions, description). By default shutil provides these formats: gztar: gzip’ed tar-file bztar: bzip2’ed tar-file (if the bz2 module is available.) xztar: xz’ed tar-file (if the lzma module is available.) tar: uncompressed tar file zip: ZIP file You can register new formats or provide your own unpacker for any existing formats, by using register

shutil.get_terminal_size()

shutil.get_terminal_size(fallback=(columns, lines)) Get the size of the terminal window. For each of the two dimensions, the environment variable, COLUMNS and LINES respectively, is checked. If the variable is defined and the value is a positive integer, it is used. When COLUMNS or LINES is not defined, which is the common case, the terminal connected to sys.__stdout__ is queried by invoking os.get_terminal_size(). If the terminal size cannot be successfully queried, either because the syste

shutil.get_archive_formats()

shutil.get_archive_formats() Return a list of supported formats for archiving. Each element of the returned sequence is a tuple (name, description). By default shutil provides these formats: gztar: gzip’ed tar-file bztar: bzip2’ed tar-file (if the bz2 module is available.) xztar: xz’ed tar-file (if the lzma module is available.) tar: uncompressed tar file zip: ZIP file You can register new formats or provide your own archiver for any existing formats, by using register_archive_format(