4 # Copyright 2009 Develer S.r.l. (http://www.develer.com/)
9 # Author: Lorenzo Berni <duplo@develer.com>
16 def copytree(src, dst, symlinks=False, ignore_list=[]):
18 Reimplementation of the shutil.copytree function that use ignore_list.
19 ignore_list is a list containing patterns to ignore during the copy.
21 names = os.listdir(src)
25 srcname = os.path.join(src, name)
26 dstname = os.path.join(dst, name)
29 for ignore in ignore_list:
30 if fnmatch.fnmatch(srcname, ignore):
35 if symlinks and os.path.islink(srcname):
36 linkto = os.readlink(srcname)
37 os.symlink(linkto, dstname)
38 elif os.path.isdir(srcname):
39 copytree(srcname, dstname, symlinks)
41 copy2(srcname, dstname)
42 # XXX What about devices, sockets etc.?
43 except (IOError, os.error), why:
44 errors.append((srcname, dstname, str(why)))
45 # catch the Error from the recursive copytree so that we can
46 # continue with other files
48 errors.extend(err.args[0])
52 # can't copy file access times on Windows
55 errors.extend((src, dst, str(why)))