Scrapy, a fast high-level web crawling & scraping framework for Python.
Added check so that genspider cannot create a spider with the same name as the project.
Tom Mortimer-Jones2efd85952591
diff --git a/scrapy/commands/genspider.py b/scrapy/commands/genspider.pyindex 39ee01367..79deb3ffb 100644--- a/scrapy/commands/genspider.py+++ b/scrapy/commands/genspider.py@@ -56,6 +56,11 @@ class Command(ScrapyCommand):name, domain = args[0:2]module = sanitize_module_name(name)++ if self.settings.get('BOT_NAME') == module:+ print "Cannot create a spider with the same name as your project"+ return+try:spider = self.crawler.spiders.create(name)except KeyError:diff --git a/scrapy/tests/test_commands.py b/scrapy/tests/test_commands.pyindex 24fa072cc..205ebe8d1 100644--- a/scrapy/tests/test_commands.py+++ b/scrapy/tests/test_commands.py@@ -112,6 +112,10 @@ class GenspiderCommandTest(CommandTest):self.assertEqual(0, self.call('genspider', '--dump=basic'))self.assertEqual(0, self.call('genspider', '-d', 'basic'))+ def test_same_name_as_project(self):+ self.assertEqual(2, self.call('genspider', self.project_name))+ assert not exists(join(self.proj_mod_path, 'spiders', '%s.py' % self.project_name))+class MiscCommandsTest(CommandTest):