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