Skip to content

Commit

Permalink
✨ [FEAT] Add images in CirkwiParser (refs #3947)
Browse files Browse the repository at this point in the history
  • Loading branch information
Chatewgne committed Nov 20, 2024
1 parent 634c153 commit 90e8703
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions geotrek/cirkwi/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -26,6 +27,9 @@ class CirkwiParser(AttachmentParserMixin, Parser):
constant_fields = {
'published': True,
}
non_fields = {
'attachments': "informations/information[@langue='<LANG>']/medias/images/image/*"
}
# Pagination : how many objects to retrieve per page
page_count = 10

Expand Down Expand Up @@ -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)
Expand All @@ -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] != '@@':
Expand Down Expand Up @@ -129,9 +132,6 @@ class CirkwiTrekParser(CirkwiParser):
"difficulty": "locomotions/locomotion@@difficulte",
"duration": "locomotions/locomotion@@duree",
}
# non_fields = {
# 'attachments': "informations/information[@langue='<LANG>']/medias/images/image/*"
# }

def filter_geom(self, src, val):
response = self.request_or_retry(url=val)
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 90e8703

Please sign in to comment.