本文整理汇总了Python中pycalendar.icalendar.calendar.Calendar.parse方法的典型用法代码示例。如果您正苦于以下问题:Python Calendar.parse方法的具体用法?Python Calendar.parse怎么用?Python Calendar.parse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pycalendar.icalendar.calendar.Calendar
的用法示例。
在下文中一共展示了Calendar.parse方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _doEquality
# 需要导入模块: from pycalendar.icalendar.calendar import Calendar [as 别名]
# 或者: from pycalendar.icalendar.calendar.Calendar import parse [as 别名]
def _doEquality(caldata):
cal1 = Calendar()
cal1.parse(StringIO.StringIO(caldata))
cal2 = Calendar()
cal2.parse(StringIO.StringIO(caldata))
self.assertEqual(cal1, cal2, "%s\n\n%s" % (cal1, cal2,))
示例2: _doDuplicateRoundtrip
# 需要导入模块: from pycalendar.icalendar.calendar import Calendar [as 别名]
# 或者: from pycalendar.icalendar.calendar.Calendar import parse [as 别名]
def _doDuplicateRoundtrip(caldata):
cal = Calendar()
cal.parse(StringIO.StringIO(caldata))
cal = cal.duplicate()
s = StringIO.StringIO()
cal.generate(s)
self.assertEqual(caldata, s.getvalue())
示例3: _doNonEquality
# 需要导入模块: from pycalendar.icalendar.calendar import Calendar [as 别名]
# 或者: from pycalendar.icalendar.calendar.Calendar import parse [as 别名]
def _doNonEquality(caldata):
cal1 = Calendar()
cal1.parse(StringIO.StringIO(caldata))
cal2 = Calendar()
cal2.parse(StringIO.StringIO(caldata))
cal2.addProperty(Property("X-FOO", "BAR"))
self.assertNotEqual(cal1, cal2)
示例4: loadCalendar
# 需要导入模块: from pycalendar.icalendar.calendar import Calendar [as 别名]
# 或者: from pycalendar.icalendar.calendar.Calendar import parse [as 别名]
def loadCalendar(file, verbose):
cal = Calendar()
if verbose:
print "Parsing calendar data: %s" % (file,)
with open(file, "r") as fin:
try:
cal.parse(fin)
except InvalidData, e:
print "Failed to parse bad data: %s" % (e.mData,)
raise
示例5: _doRoundtrip
# 需要导入模块: from pycalendar.icalendar.calendar import Calendar [as 别名]
# 或者: from pycalendar.icalendar.calendar.Calendar import parse [as 别名]
def _doRoundtrip(caldata, resultdata=None):
test1 = resultdata if resultdata is not None else caldata
cal = Calendar()
cal.parse(StringIO.StringIO(caldata))
test2 = cal.getTextXML()
self.assertEqual(
test1,
test2,
"\n".join(difflib.unified_diff(str(test1).splitlines(), test2.splitlines()))
)
示例6: testAddCN
# 需要导入模块: from pycalendar.icalendar.calendar import Calendar [as 别名]
# 或者: from pycalendar.icalendar.calendar.Calendar import parse [as 别名]
def testAddCN(self):
data = (
"""BEGIN:VCALENDAR
VERSION:2.0
CALSCALE:GREGORIAN
PRODID:-//mulberrymail.com//Mulberry v4.0//EN
BEGIN:VEVENT
UID:C3184A66-1ED0-11D9-A5E0-000A958A3252
DTSTART;VALUE=DATE:20020101
DTEND;VALUE=DATE:20020102
DTSTAMP:20020101T000000Z
RRULE:FREQ=YEARLY;UNTIL=20031231;BYMONTH=1
ORGANIZER:[email protected]
SUMMARY:New Year's Day
END:VEVENT
END:VCALENDAR
""".replace("\n", "\r\n"),
"まだ",
"""BEGIN:VCALENDAR
VERSION:2.0
CALSCALE:GREGORIAN
PRODID:-//mulberrymail.com//Mulberry v4.0//EN
BEGIN:VEVENT
UID:C3184A66-1ED0-11D9-A5E0-000A958A3252
DTSTART;VALUE=DATE:20020101
DTEND;VALUE=DATE:20020102
DTSTAMP:20020101T000000Z
RRULE:FREQ=YEARLY;UNTIL=20031231;BYMONTH=1
ORGANIZER;CN=まだ:[email protected]
SUMMARY:New Year's Day
END:VEVENT
END:VCALENDAR
""".replace("\n", "\r\n"),
)
cal1 = Calendar()
cal1.parse(StringIO.StringIO(data[0]))
vevent = cal1.getComponents("VEVENT")[0]
organizer = vevent.getProperties("ORGANIZER")[0]
organizer.addParameter(Parameter("CN", data[1]))
cal2 = Calendar()
cal2.parse(StringIO.StringIO(data[2]))
self.assertEqual(str(cal1), str(cal2))
示例7: testDuplicateWithRecurrenceChange
# 需要导入模块: from pycalendar.icalendar.calendar import Calendar [as 别名]
# 或者: from pycalendar.icalendar.calendar.Calendar import parse [as 别名]
def testDuplicateWithRecurrenceChange(self):
data = (
"""BEGIN:VCALENDAR
VERSION:2.0
CALSCALE:GREGORIAN
PRODID:-//mulberrymail.com//Mulberry v4.0//EN
BEGIN:VEVENT
UID:C3184A66-1ED0-11D9-A5E0-000A958A3252
DTSTART;VALUE=DATE:20020101
DTEND;VALUE=DATE:20020102
DTSTAMP:20020101T000000Z
RRULE:FREQ=YEARLY
SUMMARY:New Year's Day
END:VEVENT
END:VCALENDAR
""".replace("\n", "\r\n"),
"""BEGIN:VCALENDAR
VERSION:2.0
CALSCALE:GREGORIAN
PRODID:-//mulberrymail.com//Mulberry v4.0//EN
BEGIN:VEVENT
UID:C3184A66-1ED0-11D9-A5E0-000A958A3252
DTSTART;VALUE=DATE:20020101
DTEND;VALUE=DATE:20020102
DTSTAMP:20020101T000000Z
RRULE:FREQ=YEARLY;COUNT=400
SUMMARY:New Year's Day
END:VEVENT
END:VCALENDAR
""".replace("\n", "\r\n"),
)
cal1 = Calendar()
cal1.parse(StringIO.StringIO(data[0]))
cal2 = cal1.duplicate()
vevent = cal2.getComponents()[0]
rrules = vevent.getRecurrenceSet()
for rrule in rrules.getRules():
rrule.setUseCount(True)
rrule.setCount(400)
rrules.changed()
self.assertEqual(data[0], str(cal1))
self.assertEqual(data[1], str(cal2))
示例8: usage
# 需要导入模块: from pycalendar.icalendar.calendar import Calendar [as 别名]
# 或者: from pycalendar.icalendar.calendar.Calendar import parse [as 别名]
for option, value in options:
if option == "-h":
usage()
else:
usage("Unrecognized option: %s" % (option,))
# Process arguments
if len(args) != 1:
usage("Must have one argument")
pwd = os.getcwd()
analyzers = []
for arg in args:
arg = os.path.expanduser(arg)
if not arg.startswith("/"):
arg = os.path.join(pwd, arg)
if arg.endswith("/"):
arg = arg[:-1]
if not os.path.exists(arg):
print("Path does not exist: '%s'. Ignoring." % (arg,))
continue
cal = Calendar()
cal.parse(open(arg))
print(str(cal.serialize()))
except Exception, e:
sys.exit(str(e))
print(traceback.print_exc())
示例9: testParseComponent
# 需要导入模块: from pycalendar.icalendar.calendar import Calendar [as 别名]
# 或者: from pycalendar.icalendar.calendar.Calendar import parse [as 别名]
def testParseComponent(self):
data1 = """BEGIN:VCALENDAR
VERSION:2.0
CALSCALE:GREGORIAN
PRODID:-//mulberrymail.com//Mulberry v4.0//EN
BEGIN:VEVENT
UID:C3184A66-1ED0-11D9-A5E0-000A958A3252
DTSTART;VALUE=DATE:20020101
DTEND;VALUE=DATE:20020102
DTSTAMP:20020101T000000Z
RRULE:FREQ=YEARLY;UNTIL=20031231;BYMONTH=1
SUMMARY:New Year's Day
END:VEVENT
END:VCALENDAR
""".replace("\n", "\r\n")
data2 = """BEGIN:VCALENDAR
VERSION:2.0
CALSCALE:GREGORIAN
PRODID:-//Example Inc.//Example Calendar//EN
BEGIN:VTIMEZONE
TZID:America/Montreal
LAST-MODIFIED:20040110T032845Z
BEGIN:DAYLIGHT
DTSTART:20000404T020000
RRULE:FREQ=YEARLY;BYDAY=1SU;BYMONTH=4
TZNAME:EDT
TZOFFSETFROM:-0500
TZOFFSETTO:-0400
END:DAYLIGHT
BEGIN:STANDARD
DTSTART:20001026T020000
RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10
TZNAME:EST
TZOFFSETFROM:-0400
TZOFFSETTO:-0500
END:STANDARD
END:VTIMEZONE
END:VCALENDAR
""".replace("\n", "\r\n")
result = """BEGIN:VCALENDAR
VERSION:2.0
CALSCALE:GREGORIAN
PRODID:-//mulberrymail.com//Mulberry v4.0//EN
BEGIN:VTIMEZONE
TZID:America/Montreal
LAST-MODIFIED:20040110T032845Z
BEGIN:DAYLIGHT
DTSTART:20000404T020000
RRULE:FREQ=YEARLY;BYDAY=1SU;BYMONTH=4
TZNAME:EDT
TZOFFSETFROM:-0500
TZOFFSETTO:-0400
END:DAYLIGHT
BEGIN:STANDARD
DTSTART:20001026T020000
RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10
TZNAME:EST
TZOFFSETFROM:-0400
TZOFFSETTO:-0500
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
UID:C3184A66-1ED0-11D9-A5E0-000A958A3252
DTSTART;VALUE=DATE:20020101
DTEND;VALUE=DATE:20020102
DTSTAMP:20020101T000000Z
RRULE:FREQ=YEARLY;UNTIL=20031231;BYMONTH=1
SUMMARY:New Year's Day
END:VEVENT
END:VCALENDAR
""".replace("\n", "\r\n")
cal = Calendar()
cal.parse(StringIO.StringIO(data1))
cal.parseComponent(StringIO.StringIO(data2))
self.assertEqual(str(cal), result)