Exemple #1
0
 def tourLoc(self, tl):
         if tl is None:
             return None
         typ = tl.get("Type")
         if typ != "Startpunkt" and typ != "Treffpunkt" and typ != "Zielort":
             return None
         beginning = tl.get("Beginning")
         logger.debug("beginning %s", beginning)  # '2018-04-24T12:00:00'
         beginning = event.convertToMEZOrMSZ(beginning)  # '2018-04-24T14:00:00'
         beginning = beginning[11:16]  # 14:00
         name = tl.get("Name")
         street = tl.get("Street")
         city = tl.get("City")
         logger.debug("name '%s' street '%s' city '%s'", name, street, city)
         loc = name
         if city != "":
             if loc == "":
                 loc = city
             else:
                 loc = loc + " " + city
         if street != "":
             if loc == "":
                 loc = street
             else:
                 loc = loc + " " + street
         if typ == "Startpunkt":
             if self.isTermin():
                 typ = "Treffpunkt"
             else:
                 typ = "Start"
         if typ == "Zielort":
             typ = "Ziel"
         return (typ, beginning, loc)
Exemple #2
0
 def getEndDatum(self):
     beginning = self.eventItem.get("End")
     datum = event.convertToMEZOrMSZ(beginning)  # '2018-04-24T14:00:00'
     logger.debug("datum <%s>", str(datum))
     day = str(datum[0:10])
     date = time.strptime(day, "%Y-%m-%d")
     weekday = event.weekdays[date.tm_wday]
     res = (weekday + ", " + day[8:10] + "." + day[5:7] + "." + day[0:4], datum[11:16])
     return res
Exemple #3
0
 def getEndDatum(self):
     enddatum = self.eventItem.get("end")
     enddatum = event.convertToMEZOrMSZ(enddatum)
     # fromisoformat defined in Python3.7, not used by Scribus
     # enddatum = datetime.fromisoformat(enddatum)
     logger.debug("enddatum %s", str(enddatum))
     day = str(enddatum[0:10])
     date = time.strptime(day, "%Y-%m-%d")
     weekday = event.weekdays[date.tm_wday]
     res = (weekday + ", " + day[8:10] + "." + day[5:7] + "." + day[0:4],
            enddatum[11:16])
     return res
Exemple #4
0
 def getDatum(self):
     datum = self.eventItem.get("beginning")
     datum = event.convertToMEZOrMSZ(datum)
     # fromisoformat defined in Python3.7, not used by Scribus
     # date = datetime.fromisoformat(datum)
     logger.debug("datum <%s>", str(datum))
     day = str(datum[0:10])
     date = time.strptime(day, "%Y-%m-%d")
     weekday = event.weekdays[date.tm_wday]
     res = (weekday + ", " + day[8:10] + "." + day[5:7] + "." + day[0:4],
            datum[11:16], datum)
     return res
Exemple #5
0
    def getEvents(self, unitKey, start, end, typ):
        unit = "Alles" if unitKey is None or unitKey == "" else unitKey
        startYear = start[0:4]

        with open(self.fn, "r", encoding="utf-8") as f:
            f = XMLFilter(f)
            xmlt = parse(f)
        n, d = parse_element(xmlt)
        jsRoot = elimText(d)
        # jsonPath = "xml2.json"
        # with open(jsonPath, "w") as jsonFile:
        #     json.dump(jsRoot, jsonFile, indent=4)
        js = jsRoot.get("ExportEventItemList")
        js = js.get("EventItems")
        items = js.get("ExportEventItem")
        events = []
        if len(items) == 0:
            return events
        for item in iter(items):
            # item["imagePreview"] = ""  # save space
            titel = item.get("Title")
            if titel is None:
                logger.error("Kein Titel für den Event %s", str(item))
                continue
            if item.get("IsCancelled") != "Nein":
                logger.info("Event %s ist gecancelt", titel)
                continue
            if typ != "Alles" and item.get("EventType") != typ:
                continue
            beginning = item.get("Beginning")
            if beginning is None:
                logger.error("Kein Beginn für den Event %s", titel)
                continue
            begDate = beginning[0:4]
            if begDate < start[0:4] or begDate > end[0:4]:
                continue
            ev = XmlEvent(item)
            if ev.isTermin():
                self.alleTermine.append(ev)
            else:
                self.alleTouren.append(ev)
            begDate = event.convertToMEZOrMSZ(beginning)[0:10]
            if begDate < start or begDate > end:
                logger.info("event " + titel + " not in timerange")
                continue
            # add other filter conditions here
            logger.info("event " + titel + " OK")
            self.events[ev.getEventItemId()] = ev
        return self.events.values()
Exemple #6
0
 def getDatum(self):
     """
         "Beginning": "2020-05-24T05:00:00",
         "BeginningDate": "24/05/2020",
         "BeginningTime": "05:00:00",
         "End": "2020-05-24T17:00:00",
         "EndDate": "24/05/2020",
         "EndTime": "05:00:00",
     """
     beginning = self.eventItem.get("Beginning")
     datum = event.convertToMEZOrMSZ(beginning)  # '2018-04-24T14:00:00'
     logger.debug("datum <%s>", str(datum))
     day = str(datum[0:10])
     date = time.strptime(day, "%Y-%m-%d")
     weekday = event.weekdays[date.tm_wday]
     res = (weekday + ", " + day[8:10] + "." + day[5:7] + "." + day[0:4], datum[11:16])
     return res
Exemple #7
0
 def getAbfahrten(self):
     abfahrten = []
     for tourLoc in self.tourLocations:
         typ = tourLoc.get("type")
         logger.debug("typ %s", typ)
         if typ != "Startpunkt" and typ != "Treffpunkt":
             continue
         if not tourLoc.get("withoutTime"):
             if len(
                     abfahrten
             ) == 0:  # for first loc, get starttime from eventItem, beginning in tourloc is often wrong
                 beginning = self.getDatum()[1]
             else:
                 beginning = tourLoc.get("beginning")
                 logger.debug("beginning %s",
                              beginning)  # '2018-04-24T12:00:00'
                 beginning = event.convertToMEZOrMSZ(
                     beginning)  # '2018-04-24T14:00:00'
                 beginning = beginning[11:16]  # 14:00
         else:
             beginning = ""
         name = tourLoc.get("name")
         street = tourLoc.get("street")
         city = tourLoc.get("city")
         logger.debug("name '%s' street '%s' city '%s'", name, street, city)
         loc = name
         if city != "":
             if loc == "":
                 loc = city
             else:
                 loc = loc + " " + city
         if street != "":
             if loc == "":
                 loc = street
             else:
                 loc = loc + " " + street
         if typ == "Startpunkt":
             if self.isTermin():
                 typ = "Treffpunkt"
             else:
                 typ = "Start"
         abfahrt = (typ, beginning, loc)
         abfahrten.append(abfahrt)
     return abfahrten
Exemple #8
0
 def getPublishDate(self):
     datum = self.eventItem.get("cPublishDate")
     datum = event.convertToMEZOrMSZ(datum)
     return datum