Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python code in get_noaa_smoke does not pass pep8 check #2

Open
brianhigh opened this issue Jul 3, 2019 · 0 comments
Open

python code in get_noaa_smoke does not pass pep8 check #2

brianhigh opened this issue Jul 3, 2019 · 0 comments

Comments

@brianhigh
Copy link
Member

When testing the coding style compliance of the python code in the get_noaa_smoke demo, I found several compliance issues using pep8online.com.

Modified code which passes the pep8 tests follows:

import re
import os.path
import urlparse
import scrapy
from scrapy.http import Request
from scrapy.crawler import CrawlerProcess


class get_hms_shapefiles(scrapy.Spider):
    """Get daily SMOKE files from May through Sept. for the years 2008-2017."""
    name = "get_hms_shapefiles"
    domain = "satepsanone.nesdis.noaa.gov"
    allowed_domains = [domain]
    start_urls = ["http://%s/pub/volcano/FIRE/HMS_ARCHIVE/%s/GIS/SMOKE/" %
                  (domain, year) for year in range(2008, 2017)]

    def parse(self, response):
        for href in response.xpath('//a/@href').extract():
            regexp = r'hms_smoke[0-9]{4}0[5-9]{1}[0-9]{2}\.(dbf|shp|shx)\.gz$'
            if re.match(regexp, href):
                yield Request(url=response.urljoin(href),
                              callback=self.save_file)

    def save_file(self, response):
        path = response.url.split('/')[-1]
        if not os.path.exists(path):
            with open(path, 'wb') as f:
                f.write(response.body)

process = CrawlerProcess()
process.crawl(get_hms_shapefiles) & process.start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant