def execute(self, args): events = self.getEvents() calendar = Calendar() for event in events: calendar.add_component(event) calendar.add('X-WR-CALNAME', "Noisebridge Event Calendar") calendar.add('X-WR-TIMEZONE', pytz.timezone("America/Los_Angeles")) calendar.add( 'X-WR-CALDESC', "Events and happenings from the Noisebridge Hacker Space") calendar.add('version', '2.0') calendar.add('prodid', '-//Phong Robotics//Phong Phongy Phoo//EN') calendar.add('X-PUBLISHED-TTL', 'PT1H') print calendar.to_ical()
def icsout(inp): from icalendar.cal import Calendar, Event from hashlib import sha1 inp = os.path.expanduser(inp) cal = Calendar() cal.add('prodid', '-//ccal.py 0.5//niij.org//') cal.add('version', '2.0') entries = Entries(every=True, comm=True) for entry in entries: event = Event() event.add('summary', entry.desc) event.add('dtstart', entry.dt) event.add('dtend', entry.dt + dt.timedelta(days=1)) event.add('dtstamp', dt.datetime.now()) uid = "%s%s%s %s" % (entry.dt.year, entry.dt.month, entry.dt.day, entry.desc) event.add('uid', sha1(uid.encode('utf-8')).hexdigest()) if (entry.comm): event.add('description', entry.comm.strip()) cal.add_component(event) print(cal.to_ical().decode('utf-8')) sys.exit(0)
verb="cancel") for recipient in recipients ] def to_ical(self): """Returns iCalendar event object. Returns: Calendar """ event = CalendarEvent() starts = self.get_next_starts_with_tz() event.add("dtstart", starts) event.add("dtstamp", starts) if ends := self.get_next_ends_with_tz(): event.add("dtend", ends) event.add("summary", self.title) if location := self.get_full_location(): event.add("location", location) if self.description: event.add("description", self.description.plaintext().splitlines()) calendar = Calendar() calendar.add_component(event) return calendar.to_ical()