Scrapy, a fast high-level web crawling & scraping framework for Python.
Simplified copytree function
Felipe Ruhlandfc9a45ee9129
diff --git a/scrapy/commands/startproject.py b/scrapy/commands/startproject.pyindex 4da129865..c0e7af88a 100644--- a/scrapy/commands/startproject.py+++ b/scrapy/commands/startproject.py@@ -52,47 +52,25 @@ class Command(ScrapyCommand):return Truereturn False- def _copytree(self, src, dst, symlinks=False, ignore=None):+ def _copytree(self, src, dst):+ ignore = IGNOREnames = os.listdir(src)- if ignore is not None:- ignored_names = ignore(src, names)- else:- ignored_names = set()+ ignored_names = ignore(src, names)if not os.path.exists(dst):os.makedirs(dst)- errors = []for name in names:if name in ignored_names:continue+srcname = os.path.join(src, name)dstname = os.path.join(dst, name)- try:- if symlinks and os.path.islink(srcname):- linkto = os.readlink(srcname)- os.symlink(linkto, dstname)- elif os.path.isdir(srcname):- self._copytree(srcname, dstname, symlinks, ignore)- else:- # Will raise a SpecialFileError for unsupported file types- copy2(srcname, dstname)- # catch the Error from the recursive copytree so that we can- # continue with other files- except EnvironmentError as err:- errors.extend(err.args[0])- except EnvironmentError as why:- errors.append((srcname, dstname, str(why)))- try:- copystat(src, dst)- except OSError as why:- if WindowsError is not None and isinstance(why, WindowsError):- # Copying file access times may fail on Windows- pass+ if os.path.isdir(srcname):+ self._copytree(srcname, dstname)else:- errors.append((src, dst, str(why)))- if errors:- raise EnvironmentError(errors)+ copy2(srcname, dstname)+ copystat(src, dst)def run(self, args, opts):if len(args) not in (1, 2):@@ -112,7 +90,7 @@ class Command(ScrapyCommand):self.exitcode = 1return- self._copytree(self.templates_dir, abspath(project_dir), ignore=IGNORE)+ self._copytree(self.templates_dir, abspath(project_dir))move(join(project_dir, 'module'), join(project_dir, project_name))for paths in TEMPLATES_TO_RENDER:path = join(*paths)