From 90e87033767e99cba79f3b90388cb01dbfa1a715 Mon Sep 17 00:00:00 2001 From: Chatewgne Date: Fri, 15 Nov 2024 10:14:34 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20[FEAT]=20Add=20images=20in=20Cirkwi?= =?UTF-8?q?Parser=20(refs=20#3947)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- geotrek/cirkwi/parsers.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/geotrek/cirkwi/parsers.py b/geotrek/cirkwi/parsers.py index 9dcffb5ca5..5237cc2bb0 100644 --- a/geotrek/cirkwi/parsers.py +++ b/geotrek/cirkwi/parsers.py @@ -12,6 +12,7 @@ from geotrek.trekking.models import Trek, Practice from geotrek.trekking.parsers import ApidaeTrekParser + class CirkwiParser(AttachmentParserMixin, Parser): update_only = False delete = False @@ -26,6 +27,9 @@ class CirkwiParser(AttachmentParserMixin, Parser): constant_fields = { 'published': True, } + non_fields = { + 'attachments': "informations/information[@langue='']/medias/images/image/*" + } # Pagination : how many objects to retrieve per page page_count = 10 @@ -64,7 +68,7 @@ def next_row(self): self.nb = int(ET.fromstring(response.content).find("listing_ids", {}).attrib['nb_objects']) # Make several requests for pagination first = 0 - while first <= self.nb : + while first <= self.nb: params['first'] = first params['rows'] = self.page_count response = requests.get(self.url, params=params, auth=self.auth) @@ -77,7 +81,6 @@ def next_row(self): yield row first += self.page_count - def get_part(self, dst, src, val): # Recursively extract XML attributes if '@@' in src and src[:2] != '@@': @@ -129,9 +132,6 @@ class CirkwiTrekParser(CirkwiParser): "difficulty": "locomotions/locomotion@@difficulte", "duration": "locomotions/locomotion@@duree", } - # non_fields = { - # 'attachments': "informations/information[@langue='']/medias/images/image/*" - # } def filter_geom(self, src, val): response = self.request_or_retry(url=val) @@ -170,7 +170,7 @@ def filter_practice(self, src, val): def filter_duration(self, src, val): if val != "0": - return int(val)/3600 + return int(val) / 3600 return None def filter_difficulty(self, src, val):