# Copyright 2008 Develer S.r.l. (http://www.develer.com/)
# All rights reserved.
#
-# $Id:$
+# $Id$
#
# Author: Lorenzo Berni <duplo@develer.com>
#
import glob
import re
import shutil
+# Use custom copytree function
+import copytree
import pickle
import const
# Destination source dir
srcdir = directory + "/bertos"
shutil.rmtree(srcdir, True)
- shutil.copytree(sources_dir + "/bertos", srcdir)
+ copytree.copytree(sources_dir + "/bertos", srcdir, ignore_list=const.IGNORE_LIST)
# Destination makefile
makefile = directory + "/Makefile"
if os.path.exists(makefile):
--- /dev/null
+#!/usr/bin/env python
+# encoding: utf-8
+#
+# Copyright 2009 Develer S.r.l. (http://www.develer.com/)
+# All rights reserved.
+#
+# $Id:$
+#
+# Author: Lorenzo Berni <duplo@develer.com>
+#
+
+import os
+import fnmatch
+from shutil import *
+
+def copytree(src, dst, symlinks=False, ignore_list=[]):
+ """
+ Reimplementation of the shutil.copytree function that use ignore_list.
+ ignore_list is a list containing patterns to ignore during the copy.
+ """
+ names = os.listdir(src)
+ os.makedirs(dst)
+ errors = []
+ for name in names:
+ srcname = os.path.join(src, name)
+ dstname = os.path.join(dst, name)
+ try:
+ ignored = False
+ for ignore in ignore_list:
+ if fnmatch.fnmatch(srcname, ignore):
+ ignored = True
+ break
+ if ignored:
+ continue
+ if symlinks and os.path.islink(srcname):
+ linkto = os.readlink(srcname)
+ os.symlink(linkto, dstname)
+ elif os.path.isdir(srcname):
+ copytree(srcname, dstname, symlinks)
+ else:
+ copy2(srcname, dstname)
+ # XXX What about devices, sockets etc.?
+ except (IOError, os.error), why:
+ errors.append((srcname, dstname, str(why)))
+ # catch the Error from the recursive copytree so that we can
+ # continue with other files
+ except Error, err:
+ errors.extend(err.args[0])
+ try:
+ copystat(src, dst)
+ except WindowsError:
+ # can't copy file access times on Windows
+ pass
+ except OSError, why:
+ errors.extend((src, dst, str(why)))
+ if errors:
+ raise Error, errors