Skip to content

Commit

Permalink
feat(italy_anac): set release ids as ocid when no ocid is present
Browse files Browse the repository at this point in the history
  • Loading branch information
yolile committed Nov 13, 2023
1 parent 360c7c4 commit b063e8e
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion kingfisher_scrapy/spiders/italy_anac.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import scrapy

from kingfisher_scrapy.base_spiders import SimpleSpider
from kingfisher_scrapy.util import components, handle_http_error
from kingfisher_scrapy.util import components, handle_http_error, json_dumps


class ItalyANAC(SimpleSpider):
Expand Down Expand Up @@ -30,3 +30,12 @@ def parse_list(self, response):
for resource in result['resources']:
if resource['format'].upper() == 'JSON':
yield self.build_request(resource['url'], formatter=components(-2))

@handle_http_error
def parse(self, response):
data = response.json()
for release in data['releases']:
if 'ocid' not in release:
release['ocid'] = '-'.join(release['id'].split('-')[:3])
response = response.replace(body=json_dumps(data))
yield from super().parse(response)

0 comments on commit b063e8e

Please sign in to comment.