当前位置: 首页>>代码示例>>Python>>正文


Python vobject.iCalendar方法代码示例

本文整理汇总了Python中vobject.iCalendar方法的典型用法代码示例。如果您正苦于以下问题:Python vobject.iCalendar方法的具体用法?Python vobject.iCalendar怎么用?Python vobject.iCalendar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在vobject的用法示例。


在下文中一共展示了vobject.iCalendar方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: calendar2ical

# 需要导入模块: import vobject [as 别名]
# 或者: from vobject import iCalendar [as 别名]
def calendar2ical(self):
        '''
        Return an iCalendar object for the given calendar_id containing
        all the vevent objects
        '''
        Event = Pool().get('calendar.event')

        ical = vobject.iCalendar()
        ical.vevent_list = []
        events = Event.search([
                ('calendar', '=', self.id),
                ('parent', '=', None),
                ])
        for event in events:
            ical2 = event.event2ical()
            ical.vevent_list.extend(ical2.vevent_list)
        return ical 
开发者ID:GNUHealth-Mosconi,项目名称:health-mosconi,代码行数:19,代码来源:calendar_.py

示例2: get

# 需要导入模块: import vobject [as 别名]
# 或者: from vobject import iCalendar [as 别名]
def get(self, request, event, **kwargs):
        schedule = self.get_object()
        netloc = urlparse(get_base_url(request.event)).netloc

        cal = vobject.iCalendar()
        cal.add('prodid').value = '-//pretalx//{}//'.format(netloc)
        creation_time = datetime.now(pytz.utc)

        talks = schedule.talks.filter(
            is_visible=True
        ).prefetch_related('submission__speakers').select_related('submission', 'room').order_by('start')
        for talk in talks:
            talk.build_ical(cal, creation_time=creation_time, netloc=netloc)

        resp = HttpResponse(cal.serialize(), content_type='text/calendar')
        resp['Content-Disposition'] = f'attachment; filename="{request.event.slug}.ics"'
        return resp 
开发者ID:pretalx,项目名称:pretalx,代码行数:19,代码来源:schedule.py

示例3: serialize

# 需要导入模块: import vobject [as 别名]
# 或者: from vobject import iCalendar [as 别名]
def serialize(self):
        """Get the unicode string representing the whole collection."""
        import datetime
        items = []
        time_begin = datetime.datetime.now()
        for href in self.list():
            items.append(self.get(href).item)
        time_end = datetime.datetime.now()
        self.logger.info(
            "Collection read %d items in %s sec from %s", len(items),
            (time_end - time_begin).total_seconds(), self.path)
        if self.get_meta("tag") == "VCALENDAR":
            collection = vobject.iCalendar()
            for item in items:
                for content in ("vevent", "vtodo", "vjournal"):
                    if content in item.contents:
                        for item_part in getattr(item, "%s_list" % content):
                            collection.add(item_part)
                        break
            return collection.serialize()
        elif self.get_meta("tag") == "VADDRESSBOOK":
            return "".join([item.serialize() for item in items])
        return "" 
开发者ID:etesync,项目名称:radicale_storage_etesync,代码行数:25,代码来源:__init__.py

示例4: test0010create_event_external

# 需要导入模块: import vobject [as 别名]
# 或者: from vobject import iCalendar [as 别名]
def test0010create_event_external(self):
        'Create event with external attendee'
        ical = vobject.iCalendar()
        vevent = ical.add('vevent')
        vevent.add('summary')
        vevent.summary.value = 'Test event with external attendee'
        vevent.add('dtstart')
        vevent.dtstart.value = datetime.datetime.now() + relativedelta(days=10)
        vevent.add('dtend')
        vevent.dtend.value = datetime.datetime.now() + relativedelta(days=10,
            hours=4)
        vevent.add('organizer')
        vevent.organizer.value = '[email protected]'
        attendee = vobject.base.ContentLine('ATTENDEE', [], '')
        attendee.partstat_param = 'TENTATIVE'
        attendee.value = 'MAILTO:[email protected]'
        vevent.attendee_list = [attendee]
        caldav.Event(self.client, data=ical.serialize(),
            parent=self.calendar).save() 
开发者ID:kret0s,项目名称:gnuhealth-live,代码行数:21,代码来源:scenario_calendar_scheduling.py

示例5: test0020create_event_ext_int

# 需要导入模块: import vobject [as 别名]
# 或者: from vobject import iCalendar [as 别名]
def test0020create_event_ext_int(self):
        'Create event with external and internal attendees'
        ical = vobject.iCalendar()
        vevent = ical.add('vevent')
        vevent.add('summary')
        vevent.summary.value = 'Test event with ext/int attendees'
        vevent.add('dtstart')
        vevent.dtstart.value = datetime.datetime.now() + relativedelta(days=5)
        vevent.add('dtend')
        vevent.dtend.value = datetime.datetime.now() + relativedelta(days=5,
            hours=8)
        vevent.add('organizer')
        vevent.organizer.value = '[email protected]'
        attendees = []
        for email in ('[email protected]', '[email protected]'):
            attendee = vobject.base.ContentLine('ATTENDEE', [], '')
            attendee.partstat_param = 'TENTATIVE'
            attendee.value = 'MAILTO:%s' % email
            attendees.append(attendee)
        vevent.attendee_list = attendees
        caldav.Event(self.client, data=ical.serialize(),
            parent=self.calendar).save() 
开发者ID:kret0s,项目名称:gnuhealth-live,代码行数:24,代码来源:scenario_calendar_scheduling.py

示例6: __call__

# 需要导入模块: import vobject [as 别名]
# 或者: from vobject import iCalendar [as 别名]
def __call__(self, *args, **kwargs):

        cal = vobject.iCalendar()

        for item in self.items():

            event = cal.add('vevent')

            for vkey, key in EVENT_ITEMS:
                value = getattr(self, 'item_' + key)(item)
                if value:
                    event.add(vkey).value = value

        response = HttpResponse(cal.serialize())
        response['Content-Type'] = 'text/calendar'

        return response 
开发者ID:sunlightlabs,项目名称:partytime,代码行数:19,代码来源:feeds.py

示例7: test0020create_event

# 需要导入模块: import vobject [as 别名]
# 或者: from vobject import iCalendar [as 别名]
def test0020create_event(self):
        'Create event'
        ical = vobject.iCalendar()
        vevent = ical.add('vevent')
        vevent.add('summary')
        vevent.summary.value = 'Test event'
        vevent.add('dtstart')
        vevent.dtstart.value = (datetime.datetime.now()
            + relativedelta(months=1))
        vevent.add('dtend')
        vevent.dtend.value = datetime.datetime.now() + relativedelta(months=1,
            hours=1)
        caldav.Event(self.client, data=ical.serialize(),
            parent=self.calendar).save() 
开发者ID:GNUHealth-Mosconi,项目名称:health-mosconi,代码行数:16,代码来源:scenario_calendar.py

示例8: test0050create_event_attendee

# 需要导入模块: import vobject [as 别名]
# 或者: from vobject import iCalendar [as 别名]
def test0050create_event_attendee(self):
        'Create event with attendee'
        ical = vobject.iCalendar()
        vevent = ical.add('vevent')
        vevent.add('summary')
        vevent.summary.value = 'Test event with attendee'
        vevent.add('dtstart')
        vevent.dtstart.value = datetime.datetime.now() + relativedelta(days=10)
        vevent.add('dtend')
        vevent.dtend.value = datetime.datetime.now() + relativedelta(days=10,
            hours=4)
        vevent.add('organizer')
        vevent.organizer.value = '%[email protected]' % user
        attendees = []
        for name in ('foo', 'bar'):
            attendee = vobject.base.ContentLine('ATTENDEE', [], '')
            attendee.partstat_param = 'TENTATIVE'
            attendee.value = 'MAILTO:%[email protected]' % name
            attendees.append(attendee)
        vevent.attendee_list = attendees
        caldav.Event(self.client, data=ical.serialize(),
            parent=self.calendar).save()

        Event = Model.get('calendar.event')
        owner_event, = Event.find([
                ('calendar.owner.email', '=', '%[email protected]' % user),
                ('summary', '=', vevent.summary.value),
                ])
        attendee_event, = Event.find([
                ('calendar.owner.email', '=', '[email protected]'),
                ])
        self.assertEqual(attendee_event.uuid, owner_event.uuid) 
开发者ID:GNUHealth-Mosconi,项目名称:health-mosconi,代码行数:34,代码来源:scenario_calendar.py

示例9: get

# 需要导入模块: import vobject [as 别名]
# 或者: from vobject import iCalendar [as 别名]
def get(self, request, event, **kwargs):
        talk = self.get_object().slots.get(schedule=self.request.event.current_schedule)
        netloc = urlparse(settings.SITE_URL).netloc

        cal = vobject.iCalendar()
        cal.add('prodid').value = '-//pretalx//{}//{}'.format(netloc, talk.submission.code)
        talk.build_ical(cal)

        resp = HttpResponse(cal.serialize(), content_type='text/calendar')
        resp['Content-Disposition'] = f'attachment; filename="{request.event.slug}-{talk.submission.code}.ics"'
        return resp 
开发者ID:pretalx,项目名称:pretalx,代码行数:13,代码来源:talk.py

示例10: test_unicode_multiline

# 需要导入模块: import vobject [as 别名]
# 或者: from vobject import iCalendar [as 别名]
def test_unicode_multiline():
        """
        Test multiline unicode characters
        """
        cal = iCalendar()
        cal.add('method').value = 'REQUEST'
        cal.add('vevent')
        cal.vevent.add('created').value = datetime.datetime.now()
        cal.vevent.add('summary').value = '???????? ???????'
        cal.vevent.add('description').value = ('???????? ??????? ???????? ??????? ???????? ??????? ???????? ??????? '
                                               '???????? ??????? ?????sdssd??? ???????')

        # json tries to encode as utf-8 and it would break if some chars could not be encoded
        json.dumps(cal.serialize()) 
开发者ID:eventable,项目名称:vobject,代码行数:16,代码来源:tests.py

示例11: _ical_http_response_from_event_list

# 需要导入模块: import vobject [as 别名]
# 或者: from vobject import iCalendar [as 别名]
def _ical_http_response_from_event_list( elist, filename, calname = None ):#{{{2
    """ returns an ical file with the events in ``elist`` and the name
    ``filename`` """
    if len(elist) == 1:
        icalstream = elist[0].icalendar().serialize()
    else:
        ical = vobject.iCalendar()
        ical.add('METHOD').value = 'PUBLISH' # IE/Outlook needs this
        ical.add('PRODID').value = settings.PRODID
        if calname:
            ical.add('X-WR-CALNAME').value = calname
        for event in elist:
            event.icalendar(ical)
        icalstream = ical.serialize()
    response = HttpResponse( icalstream,
            content_type = 'text/calendar;charset=UTF-8' )
    filename = unicodedata.normalize('NFKD', filename).encode('ascii','ignore')
    filename = filename.replace(' ','_')
    if not filename[-4:] == '.ics':
        filename = filename + '.ics'
    response['Filename'] = filename  # IE needs this
    response['Content-Disposition'] = 'attachment; filename=' + filename
    return response

# def all_events_text ( request ): #{{{1
#     """ returns a text file with all events.
#
#     >>> from django.test import Client
#     >>> from django.core.urlresolvers import reverse
#     >>> from grical.events.models import Event
#     >>> e = Event.objects.create(
#     ...         title = 'aet_test', tags = 'berlin',
#     ...         start = datetime.date.today() )
#     >>> Client().get(reverse('all_events_text')).status_code
#     200
#     >>> e.delete()
#     """
#     # TODO: stream it, see https://code.djangoproject.com/ticket/7581
#     elist = Event.objects.all()
#     text = Event.list_as_text( elist )
#     response = HttpResponse( text, content_type = 'text/text;charset=UTF-8' )
#     filename =  Site.objects.get_current().name + '_' + \
#             datetime.datetime.now().isoformat() + '.txt'
#     response['Filename'] = filename
#     response['Content-Disposition'] = 'attachment; filename=' + filename
#     return response 
开发者ID:wikical,项目名称:grical,代码行数:48,代码来源:views.py

示例12: test_ical_to_hcal

# 需要导入模块: import vobject [as 别名]
# 或者: from vobject import iCalendar [as 别名]
def test_ical_to_hcal():
        """
        Serializing iCalendar to hCalendar.

        Since Hcalendar is experimental and the behavior doesn't seem to want to load,
        This test will have to wait.


        tzs = dateutil.tz.tzical("test_files/timezones.ics")
        cal = base.newFromBehavior('hcalendar')
        self.assertEqual(
            str(cal.behavior),
            "<class 'vobject.hcalendar.HCalendar'>"
        )
        cal.add('vevent')
        cal.vevent.add('summary').value = "this is a note"
        cal.vevent.add('url').value = "http://microformats.org/code/hcalendar/creator"
        cal.vevent.add('dtstart').value = datetime.date(2006,2,27)
        cal.vevent.add('location').value = "a place"
        cal.vevent.add('dtend').value = datetime.date(2006,2,27) + datetime.timedelta(days = 2)

        event2 = cal.add('vevent')
        event2.add('summary').value = "Another one"
        event2.add('description').value = "The greatest thing ever!"
        event2.add('dtstart').value = datetime.datetime(1998, 12, 17, 16, 42, tzinfo = tzs.get('US/Pacific'))
        event2.add('location').value = "somewhere else"
        event2.add('dtend').value = event2.dtstart.value + datetime.timedelta(days = 6)
        hcal = cal.serialize()
        """
        #self.assertEqual(
        #    str(hcal),
        #    """<span class="vevent">
        #           <a class="url" href="http://microformats.org/code/hcalendar/creator">
        #             <span class="summary">this is a note</span>:
        #              <abbr class="dtstart", title="20060227">Monday, February 27</abbr>
        #              - <abbr class="dtend", title="20060301">Tuesday, February 28</abbr>
        #              at <span class="location">a place</span>
        #           </a>
        #        </span>
        #        <span class="vevent">
        #           <span class="summary">Another one</span>:
        #           <abbr class="dtstart", title="19981217T164200-0800">Thursday, December 17, 16:42</abbr>
        #           - <abbr class="dtend", title="19981223T164200-0800">Wednesday, December 23, 16:42</abbr>
        #           at <span class="location">somewhere else</span>
        #           <div class="description">The greatest thing ever!</div>
        #        </span>
        #    """
        #) 
开发者ID:eventable,项目名称:vobject,代码行数:50,代码来源:tests.py


注:本文中的vobject.iCalendar方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。