MCPcopy
hub / github.com/scrapy/scrapy / run

Method run

scrapy/commands/genspider.py:95–123  ·  view source on GitHub ↗
(self, args: list[str], opts: argparse.Namespace)

Source from the content-addressed store, hash-verified

93 )
94
95 def run(self, args: list[str], opts: argparse.Namespace) -> None:
96 assert self.settings is not None
97 if opts.list:
98 self._list_templates()
99 return
100 if opts.dump:
101 template_file = self._find_template(opts.dump)
102 if template_file:
103 print(template_file.read_text(encoding="utf-8"))
104 return
105 if len(args) != 2:
106 raise UsageError
107
108 name, url = args[0:2]
109 url = verify_url_scheme(url)
110 module = sanitize_module_name(name)
111
112 if self.settings.get("BOT_NAME") == module:
113 print("Cannot create a spider with the same name as your project")
114 return
115
116 if not opts.force and self._spider_exists(name):
117 return
118
119 template_file = self._find_template(opts.template)
120 if template_file:
121 self._genspider(module, name, url, opts.template, template_file)
122 if opts.edit:
123 self.exitcode = os.system(f'scrapy edit "{name}"') # noqa: S605
124
125 def _generate_template_variables(
126 self,

Callers

nothing calls this directly

Calls 7

_list_templatesMethod · 0.95
_find_templateMethod · 0.95
_spider_existsMethod · 0.95
_genspiderMethod · 0.95
verify_url_schemeFunction · 0.85
sanitize_module_nameFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected