def build_calendar(input_file):
    calendar = Calendar()
    calendar.add("uid", "Calendar-" + str(randint(1, 32000)))
    calendar.add_component(create_timezone())
    try:
        document = PyQuery(filename=input_file)
        for event in parse_calendar(document):
            calendar.add_component(event)
        return calendar
    except:
        raise Exception("File cannot be parsed")
def initCalendar():
	calendar = Calendar()
	calendar.add('version', '2.0')
	calendar.add('prodid', '-//Celestial events//seasky.org//')
	calendar.add('x-wr-calname', 'Celestial events')

	return calendar
Ejemplo n.º 3
0
Archivo: ccal.py Proyecto: eaon/ccal.py
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)
Ejemplo n.º 4
0
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)
Ejemplo n.º 5
0
def show_calendarevent_ics_view(context, request):
    from icalendar import Calendar
    from icalendar import Event
    from icalendar import vUri
    from webob import Response
    calendar = Calendar()
    calendar.add('prodid', '-//KARL3//Event//')
    calendar.add('version', '2.0')
    calendar.add('method', 'PUBLISH')
    event = Event()
    event['uid'] = '%s:%s' % (context.__parent__.__parent__.__name__,
                              context.docid)
    event.add('summary', context.title)
    if context.description:
        event.add('description', context.description)
    if context.location:
        event.add('location', context.location)
    event.add('dtstamp', context.modified)
    event.add('last-modified', context.modified)
    event.add('created', context.created)
    event.add('dtstart', context.startDate)
    event.add('dtend', context.endDate)

    contacts = []
    if context.contact_name:
        contacts.append(context.contact_name)
    if context.contact_email:
        contacts.append(context.contact_email)
    if contacts:
        event.add('contact', ', '.join(contacts))

    for name in context.attendees:
        if isinstance(name, unicode):
            name = name.encode('UTF-8')
        event.add('attendee', name)

    for f in context['attachments'].values():
        attachment = vUri(model_url(f, request))
        attachment.params['fmttype'] = f.mimetype
        event.add('attach', attachment)

    calendar.add_component(event)
    return Response(body=calendar.as_string(),
                    content_type='text/calendar',
                    charset='UTF8',
                   )
Ejemplo n.º 6
0
 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()
Ejemplo n.º 7
0
 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()