Merge pull request #1472 from croneter/py3-fix-attributeerror
Fix AttributeError: module 'shutil' has no attribute 'copy_tree'
This commit is contained in:
commit
f33152049e
2 changed files with 39 additions and 20 deletions
|
@ -20,10 +20,10 @@ SHOULD_CANCEL = None
|
||||||
LIBRARY_PATH = path_ops.translate_path('special://profile/library/video/')
|
LIBRARY_PATH = path_ops.translate_path('special://profile/library/video/')
|
||||||
# The video library might not yet exist for this user - create it
|
# The video library might not yet exist for this user - create it
|
||||||
if not path_ops.exists(LIBRARY_PATH):
|
if not path_ops.exists(LIBRARY_PATH):
|
||||||
path_ops.copy_tree(
|
path_ops.copytree(
|
||||||
src=path_ops.translate_path('special://xbmc/system/library/video'),
|
src=path_ops.translate_path('special://xbmc/system/library/video'),
|
||||||
dst=LIBRARY_PATH,
|
dst=LIBRARY_PATH,
|
||||||
preserve_mode=0) # dont copy permission bits so we have write access!
|
copy_function=path_ops.shutil.copyfile)
|
||||||
PLAYLISTS_PATH = path_ops.translate_path("special://profile/playlists/video/")
|
PLAYLISTS_PATH = path_ops.translate_path("special://profile/playlists/video/")
|
||||||
if not path_ops.exists(PLAYLISTS_PATH):
|
if not path_ops.exists(PLAYLISTS_PATH):
|
||||||
path_ops.makedirs(PLAYLISTS_PATH)
|
path_ops.makedirs(PLAYLISTS_PATH)
|
||||||
|
|
|
@ -165,28 +165,47 @@ def walk(top, topdown=True, onerror=None, followlinks=False):
|
||||||
[x for x in nondirs])
|
[x for x in nondirs])
|
||||||
|
|
||||||
|
|
||||||
def copy_tree(src, dst, *args, **kwargs):
|
def copytree(src, dst, *args, **kwargs):
|
||||||
"""
|
"""
|
||||||
Copy an entire directory tree 'src' to a new location 'dst'.
|
Recursively copy an entire directory tree rooted at src to a directory named
|
||||||
|
dst and return the destination directory. dirs_exist_ok dictates whether to
|
||||||
|
raise an exception in case dst or any missing parent directory already
|
||||||
|
exists.
|
||||||
|
|
||||||
Both 'src' and 'dst' must be directory names. If 'src' is not a
|
Permissions and times of directories are copied with copystat(), individual
|
||||||
directory, raise DistutilsFileError. If 'dst' does not exist, it is
|
files are copied using copy2().
|
||||||
created with 'mkpath()'. The end result of the copy is that every
|
|
||||||
file in 'src' is copied to 'dst', and directories under 'src' are
|
|
||||||
recursively copied to 'dst'. Return the list of files that were
|
|
||||||
copied or might have been copied, using their output name. The
|
|
||||||
return value is unaffected by 'update' or 'dry_run': it is simply
|
|
||||||
the list of all files under 'src', with the names changed to be
|
|
||||||
under 'dst'.
|
|
||||||
|
|
||||||
'preserve_mode' and 'preserve_times' are the same as for
|
If symlinks is true, symbolic links in the source tree are represented as
|
||||||
'copy_file'; note that they only apply to regular files, not to
|
symbolic links in the new tree and the metadata of the original links will
|
||||||
directories. If 'preserve_symlinks' is true, symlinks will be
|
be copied as far as the platform allows; if false or omitted, the contents
|
||||||
copied as symlinks (on platforms that support them!); otherwise
|
and metadata of the linked files are copied to the new tree.
|
||||||
(the default), the destination of the symlink will be copied.
|
|
||||||
'update' and 'verbose' are the same as for 'copy_file'.
|
When symlinks is false, if the file pointed by the symlink doesn’t exist, an
|
||||||
|
exception will be added in the list of errors raised in an Error exception
|
||||||
|
at the end of the copy process. You can set the optional
|
||||||
|
ignore_dangling_symlinks flag to true if you want to silence this exception.
|
||||||
|
Notice that this option has no effect on platforms that don’t support
|
||||||
|
os.symlink().
|
||||||
|
|
||||||
|
If ignore is given, it must be a callable that will receive as its arguments
|
||||||
|
the directory being visited by copytree(), and a list of its contents, as
|
||||||
|
returned by os.listdir(). Since copytree() is called recursively, the ignore
|
||||||
|
callable will be called once for each directory that is copied. The callable
|
||||||
|
must return a sequence of directory and file names relative to the current
|
||||||
|
directory (i.e. a subset of the items in its second argument); these names
|
||||||
|
will then be ignored in the copy process. ignore_patterns() can be used to
|
||||||
|
create such a callable that ignores names based on glob-style patterns.
|
||||||
|
|
||||||
|
If exception(s) occur, an Error is raised with a list of reasons.
|
||||||
|
|
||||||
|
If copy_function is given, it must be a callable that will be used to copy
|
||||||
|
each file. It will be called with the source path and the destination path
|
||||||
|
as arguments. By default, copy2() is used, but any function that supports
|
||||||
|
the same signature (like copy()) can be used.
|
||||||
|
|
||||||
|
Raises an auditing event shutil.copytree with arguments src, dst.
|
||||||
"""
|
"""
|
||||||
return shutil.copy_tree(src, dst, *args, **kwargs)
|
return shutil.copytree(src, dst, *args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
def basename(path):
|
def basename(path):
|
||||||
|
|
Loading…
Reference in a new issue