From 119752b54365d7ba5e5cd2106f2ea8e45a0aa4ed Mon Sep 17 00:00:00 2001 From: Yohanna Lisnichuk Date: Tue, 14 Nov 2023 09:19:59 -0300 Subject: [PATCH] Apply suggestions from code review Co-authored-by: James McKinney <26463+jpmckinney@users.noreply.github.com> --- kingfisher_scrapy/spiders/italy_anac.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/kingfisher_scrapy/spiders/italy_anac.py b/kingfisher_scrapy/spiders/italy_anac.py index 78b5d835a..0ad3543aa 100644 --- a/kingfisher_scrapy/spiders/italy_anac.py +++ b/kingfisher_scrapy/spiders/italy_anac.py @@ -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): @@ -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)