amélioration des comportements par défaut de l'import
This commit is contained in:
parent
fed61a8589
commit
6ac3afc0e5
@ -76,7 +76,7 @@ class Extractor(ABC):
|
||||
def clear_events(self):
|
||||
self.events = []
|
||||
|
||||
def add_event(self, title, category, start_day, location, description, tags, url=None, url_human=None, start_time=None, end_day=None, end_time=None, last_modified=None):
|
||||
def add_event(self, title, category, start_day, location, description, tags, url=None, url_human=None, start_time=None, end_day=None, end_time=None, last_modified=None, published=False):
|
||||
if title is None:
|
||||
print("ERROR: cannot import an event without name")
|
||||
return
|
||||
@ -90,7 +90,8 @@ class Extractor(ABC):
|
||||
"start_day": start_day,
|
||||
"location": location,
|
||||
"descritpion": description,
|
||||
"tags": tags
|
||||
"tags": tags,
|
||||
"published": published
|
||||
}
|
||||
if url is not None:
|
||||
event["url"] = url
|
||||
@ -146,7 +147,7 @@ class ICALExtractor(Extractor):
|
||||
return day, time
|
||||
|
||||
|
||||
def extract(self, content, url, url_human = None, default_values = None):
|
||||
def extract(self, content, url, url_human = None, default_values = None, published = False):
|
||||
print("Extracting ical events from {}".format(url))
|
||||
self.set_header(url)
|
||||
self.clear_events()
|
||||
@ -161,7 +162,9 @@ class ICALExtractor(Extractor):
|
||||
|
||||
end_day, end_time = self.get_dt_item_from_vevent(event, "DTEND")
|
||||
|
||||
location = self.default_value_if_exists(default_values, "location")
|
||||
location = self.get_item_from_vevent(event, "LOCATION")
|
||||
if location is None:
|
||||
location = Zself.default_value_if_exists(default_values, "location")
|
||||
|
||||
description = self.get_item_from_vevent(event, "DESCRIPTION")
|
||||
|
||||
@ -180,7 +183,7 @@ class ICALExtractor(Extractor):
|
||||
if rrule is not None:
|
||||
print("Recurrent event not yet supported", rrule)
|
||||
|
||||
self.add_event(title, category, start_day, location, description, tags, url=event_url, url_human=url_human, start_time=start_time, end_day=end_day, end_time=end_time, last_modified=last_modified)
|
||||
self.add_event(title, category, start_day, location, description, tags, url=event_url, url_human=url_human, start_time=start_time, end_day=end_day, end_time=end_time, last_modified=last_modified, published=published)
|
||||
|
||||
return self.get_structure()
|
||||
|
||||
@ -219,6 +222,6 @@ if __name__ == "__main__":
|
||||
url = "https://calendar.google.com/calendar/ical/programmation.lesaugustes%40gmail.com/public/basic.ics"
|
||||
url_human = "https://www.cafelesaugustes.fr/la-programmation/"
|
||||
|
||||
events = u2e.process(url, url_human, cache = "cache-augustes.ical", default_values = {"category": "Autre", "location": "Café lecture les Augustes"})
|
||||
events = u2e.process(url, url_human, cache = "cache-augustes.ical", default_values = {"category": "Autre", "location": "Café lecture les Augustes"}, published = True)
|
||||
|
||||
#print(events)
|
Loading…
Reference in New Issue
Block a user