Skip to content

Commit

Permalink
spiders: ukraine, add more doc and OCDS related fields
Browse files Browse the repository at this point in the history
Signed-off-by: Yohanna Lisnichuk <yohanitalisnichuk@gmail.com>
  • Loading branch information
yolile committed Oct 22, 2021
1 parent 4c52e34 commit d2c3d89
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions kingfisher_scrapy/spiders/ukraine.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import scrapy

from kingfisher_scrapy.base_spider import SimpleSpider
from kingfisher_scrapy.util import handle_http_error, join, components, parameters, replace_parameters, \
append_path_components
from kingfisher_scrapy.util import (append_path_components, components, handle_http_error, join, parameters,
replace_parameters)


class Ukraine(SimpleSpider):
Expand Down Expand Up @@ -46,17 +46,26 @@ def parse(self, response):
data['data']['ocid'] = data['data']['id']
# the data looks like:
# {
# "data": { tender fields }
# "data": {
# "id": "..",
# "date": "...",
# "tenderID": "",
# tender fields
# }
# }
data = {'tender': data['data']}
data = {'tender': data['data'], 'date': data['data']['date'], 'id': data['data']['id']}
else:
# the Ukraine publication doesn't have an ocid, but the tender_id field in the contract JSON
# can be used as one, as it is the same as tender.id in the tender JSON and therefore can be used to link
# both.
data['data']['ocid'] = data['data']['tender_id']
# the data looks like:
# {
# "data": { contract fields }
# "data": {
# "id": "",
# "contractID": "",
# contract fields
# }
# }
data = {'contracts': [data['data']]}
data = {'contracts': [data['data']], 'id': data['data']['id']}
yield self.build_file_from_response(response, data=data, data_type=self.data_type)

0 comments on commit d2c3d89

Please sign in to comment.