On produit un fichier json permettant l'import
This commit is contained in:
		@@ -11,7 +11,7 @@ from selenium.webdriver.chrome.service import Service
 | 
			
		||||
from selenium.webdriver.chrome.options import Options
 | 
			
		||||
import icalendar
 | 
			
		||||
from datetime import datetime, date
 | 
			
		||||
 | 
			
		||||
import json
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -164,7 +164,7 @@ class ICALExtractor(Extractor):
 | 
			
		||||
 | 
			
		||||
            location = self.get_item_from_vevent(event, "LOCATION")
 | 
			
		||||
            if location is None:
 | 
			
		||||
                location = Zself.default_value_if_exists(default_values, "location")
 | 
			
		||||
                location = self.default_value_if_exists(default_values, "location")
 | 
			
		||||
 | 
			
		||||
            description = self.get_item_from_vevent(event, "DESCRIPTION")
 | 
			
		||||
 | 
			
		||||
@@ -196,7 +196,7 @@ class URL2Events:
 | 
			
		||||
        self.downloader = downloader
 | 
			
		||||
        self.extractor = extractor
 | 
			
		||||
 | 
			
		||||
    def process(self, url, url_human = None, cache = None, default_values = None):
 | 
			
		||||
    def process(self, url, url_human = None, cache = None, default_values = None, published = False):
 | 
			
		||||
 | 
			
		||||
        if cache and os.path.exists(cache):
 | 
			
		||||
            print("Loading cache ({})".format(cache))
 | 
			
		||||
@@ -213,7 +213,7 @@ class URL2Events:
 | 
			
		||||
                with open(cache, "w") as text_file:
 | 
			
		||||
                    text_file.write(content)
 | 
			
		||||
 | 
			
		||||
        return self.extractor.extract(content, url, url_human, default_values)
 | 
			
		||||
        return self.extractor.extract(content, url, url_human, default_values, published)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
if __name__ == "__main__":
 | 
			
		||||
@@ -224,4 +224,7 @@ if __name__ == "__main__":
 | 
			
		||||
 | 
			
		||||
    events = u2e.process(url, url_human, cache = "cache-augustes.ical", default_values = {"category": "Autre", "location": "Café lecture les Augustes"}, published = True)
 | 
			
		||||
 | 
			
		||||
    #print(events)
 | 
			
		||||
    exportfile = "events-augustes.json"
 | 
			
		||||
    print("Saving events to file {}".format(exportfile))
 | 
			
		||||
    with open(exportfile, "w") as f:
 | 
			
		||||
        json.dump(events, f, indent=4, default=str)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user