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


Python Component.from_ical方法代码示例

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


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

示例1: test_cal_Component_from_ical

# 需要导入模块: from icalendar.cal import Component [as 别名]
# 或者: from icalendar.cal.Component import from_ical [as 别名]
    def test_cal_Component_from_ical(self):
        # RecurrenceIDs may contain a TZID parameter, if so, they should create
        # a tz localized datetime, otherwise, create a naive datetime
        Component = icalendar.cal.Component
        componentStr = 'BEGIN:VEVENT\nRECURRENCE-ID;TZID=America/Denver:'\
                       + '20120404T073000\nEND:VEVENT'
        component = Component.from_ical(componentStr)
        self.assertEqual(
            str(component['RECURRENCE-ID'].dt.tzinfo.zone), "America/Denver")

        componentStr = 'BEGIN:VEVENT\nRECURRENCE-ID:20120404T073000\n'\
                       + 'END:VEVENT'
        component = Component.from_ical(componentStr)
        self.assertEqual(component['RECURRENCE-ID'].dt.tzinfo, None)
开发者ID:670information,项目名称:SmartCalendar,代码行数:16,代码来源:test_unit_cal.py

示例2: test_cal_Component_from_ical

# 需要导入模块: from icalendar.cal import Component [as 别名]
# 或者: from icalendar.cal.Component import from_ical [as 别名]
    def test_cal_Component_from_ical(self):
        # Check for proper handling of TZID parameter of datetime properties
        Component = icalendar.cal.Component
        for component_name, property_name in (
            ("VEVENT", "DTSTART"),
            ("VEVENT", "DTEND"),
            ("VEVENT", "RECURRENCE-ID"),
            ("VTODO", "DUE"),
        ):
            component_str = "BEGIN:" + component_name + "\n"
            component_str += property_name + ";TZID=America/Denver:"
            component_str += "20120404T073000\nEND:" + component_name
            component = Component.from_ical(component_str)
            self.assertEqual(str(component[property_name].dt.tzinfo.zone), "America/Denver")

            component_str = "BEGIN:" + component_name + "\n"
            component_str += property_name + ":"
            component_str += "20120404T073000\nEND:" + component_name
            component = Component.from_ical(component_str)
            self.assertEqual(component[property_name].dt.tzinfo, None)
开发者ID:untitaker,项目名称:icalendar,代码行数:22,代码来源:test_unit_cal.py

示例3: test_cal_Component_to_ical_parameter_order

# 需要导入模块: from icalendar.cal import Component [as 别名]
# 或者: from icalendar.cal.Component import from_ical [as 别名]
    def test_cal_Component_to_ical_parameter_order(self):
        Component = icalendar.cal.Component
        component_str = [b"BEGIN:VEVENT", b"X-FOOBAR;C=one;A=two;B=three:helloworld.", b"END:VEVENT"]
        component = Component.from_ical(b"\r\n".join(component_str))

        sorted_str = component.to_ical().splitlines()
        assert sorted_str[0] == component_str[0]
        assert sorted_str[1] == b"X-FOOBAR;A=two;B=three;C=one:helloworld."
        assert sorted_str[2] == component_str[2]

        preserved_str = component.to_ical(sorted=False).splitlines()
        assert preserved_str == component_str
开发者ID:untitaker,项目名称:icalendar,代码行数:14,代码来源:test_unit_cal.py

示例4: test_cal_Component_from_ical

# 需要导入模块: from icalendar.cal import Component [as 别名]
# 或者: from icalendar.cal.Component import from_ical [as 别名]
    def test_cal_Component_from_ical(self):
        # Check for proper handling of TZID parameter of datetime properties
        Component = icalendar.cal.Component
        for component_name, property_name in (
            ('VEVENT', 'DTSTART'),
            ('VEVENT', 'DTEND'),
            ('VEVENT', 'RECURRENCE-ID'),
            ('VTODO', 'DUE')
        ):
            component_str = 'BEGIN:' + component_name + '\n'
            component_str += property_name + ';TZID=America/Denver:'
            component_str += '20120404T073000\nEND:' + component_name
            component = Component.from_ical(component_str)
            self.assertEqual(str(component[property_name].dt.tzinfo.zone),
                             "America/Denver")

            component_str = 'BEGIN:' + component_name + '\n'
            component_str += property_name + ':'
            component_str += '20120404T073000\nEND:' + component_name
            component = Component.from_ical(component_str)
            self.assertEqual(component[property_name].dt.tzinfo,
                             None)
开发者ID:4bic,项目名称:open_county,代码行数:24,代码来源:test_unit_cal.py

示例5: test_cal_Component_to_ical_property_order

# 需要导入模块: from icalendar.cal import Component [as 别名]
# 或者: from icalendar.cal.Component import from_ical [as 别名]
    def test_cal_Component_to_ical_property_order(self):
        Component = icalendar.cal.Component
        component_str = [b'BEGIN:VEVENT',
                         b'DTSTART:19970714T170000Z',
                         b'DTEND:19970715T035959Z',
                         b'SUMMARY:Bastille Day Party',
                         b'END:VEVENT']
        component = Component.from_ical(b'\r\n'.join(component_str))

        sorted_str = component.to_ical().splitlines()
        assert sorted_str != component_str
        assert set(sorted_str) == set(component_str)

        preserved_str = component.to_ical(sorted=False).splitlines()
        assert preserved_str == component_str
开发者ID:4bic,项目名称:open_county,代码行数:17,代码来源:test_unit_cal.py

示例6: convert_from_calendar

# 需要导入模块: from icalendar.cal import Component [as 别名]
# 或者: from icalendar.cal.Component import from_ical [as 别名]
    def convert_from_calendar(dict_calendar):
        data = {
            'format': dict_calendar['format']
        }
        if dict_calendar["format"] == CALENDAR:
            pattern = dict_calendar["pattern"]
            calendar_event = Component.from_ical(
                CalendarUtil.decode_calendar_pattern(pattern)
            )
            if isinstance(calendar_event, Event):
                calendar_event_rule = calendar_event['RRULE']
                data['frequence'] = calendar_event_rule['FREQ'][0]

                if data['frequence'] == MONTHLY and not (
                        'INTERVAL' in calendar_event['RRULE']):
                    data['date'] = ' '.join(
                        str(date)
                        for date in calendar_event_rule['BYMONTHDAY'])

                if data['frequence'] == WEEKLY and not (
                        'INTERVAL' in calendar_event['RRULE']):
                    data['day'] = ' '.join(
                        str(CALENDAR_DAY_MAPPING_DICT[day])
                        for day in calendar_event_rule['BYDAY'])

                if 'BYHOUR' in calendar_event['RRULE']:
                    data['hour'] = ' '.join(
                        str(hour) for hour in calendar_event_rule['BYHOUR'])

                if 'BYMINUTE' in calendar_event['RRULE']:
                    data['minute'] = ' '.join(
                        str(minute)
                        for minute in calendar_event_rule['BYMINUTE'])

                if 'INTERVAL' in calendar_event['RRULE']:
                    data['interval'] = ' '.join(
                        str(interval)
                        for interval in calendar_event_rule['INTERVAL'])

        return data
开发者ID:openstack,项目名称:smaug-dashboard,代码行数:42,代码来源:utils.py


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