Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: James McKinney <[email protected]>
  • Loading branch information
yolile and jpmckinney authored Nov 14, 2023
1 parent 43fb860 commit 119752b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions kingfisher_scrapy/spiders/italy_anac.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import json

import scrapy

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


class ItalyANAC(SimpleSpider):
Expand Down Expand Up @@ -35,9 +37,9 @@ def parse_list(self, response):
def parse(self, response):
data = response.json()
for release in data['releases']:
# There are some releases without an ocid which causes Kingfisher process to fail. We use the release
# id, which has the ocds-hu01ve-7608611-01 format, as a fallback.
# Kingfisher Process merges only releases with ocids. Extract the ocid from the release id as a fallback.
# For example: ocds-hu01ve-7608611 from ocds-hu01ve-7608611-01.
if 'ocid' not in release:
release['ocid'] = '-'.join(release['id'].split('-')[:3])
response = response.replace(body=json_dumps(data))
response = response.replace(body=json.dumps(data))
yield from super().parse(response)

0 comments on commit 119752b

Please sign in to comment.