scrapy / scrapy
1 7
import scrapy
2 7
from scrapy.commands import ScrapyCommand
3 7
from scrapy.utils.versions import scrapy_components_versions
4

5

6 7
class Command(ScrapyCommand):
7

8 7
    default_settings = {'LOG_ENABLED': False,
9
                        'SPIDER_LOADER_WARN_ONLY': True}
10

11 7
    def syntax(self):
12 7
        return "[-v]"
13

14 7
    def short_desc(self):
15 7
        return "Print Scrapy version"
16

17 7
    def add_options(self, parser):
18 7
        ScrapyCommand.add_options(self, parser)
19 7
        parser.add_option("--verbose", "-v", dest="verbose", action="store_true",
20
                          help="also display twisted/python/platform info (useful for bug reports)")
21

22 7
    def run(self, args, opts):
23 7
        if opts.verbose:
24 7
            versions = scrapy_components_versions()
25 7
            width = max(len(n) for (n, _) in versions)
26 7
            for name, version in versions:
27 7
                print(f"{name:<{width}} : {version}")
28
        else:
29 7
            print(f"Scrapy {scrapy.__version__}")

Read our documentation on viewing source code .

Loading