本文整理汇总了Python中pycalendar.icalendar.calendar.Calendar.getText方法的典型用法代码示例。如果您正苦于以下问题:Python Calendar.getText方法的具体用法?Python Calendar.getText怎么用?Python Calendar.getText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pycalendar.icalendar.calendar.Calendar
的用法示例。
在下文中一共展示了Calendar.getText方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: generateZoneinfoFiles
# 需要导入模块: from pycalendar.icalendar.calendar import Calendar [as 别名]
# 或者: from pycalendar.icalendar.calendar.Calendar import getText [as 别名]
def generateZoneinfoFiles(self, outputdir, minYear, maxYear=2018, links=True, windowsAliases=None, filterzones=None):
# Empty current directory
try:
for root, dirs, files in os.walk(outputdir, topdown=False):
for name in files:
os.remove(os.path.join(root, name))
for name in dirs:
os.rmdir(os.path.join(root, name))
except OSError:
pass
for zone in self.zones.itervalues():
if filterzones and zone.name not in filterzones:
continue
cal = Calendar()
vtz = zone.vtimezone(cal, self.rules, minYear, maxYear)
cal.addComponent(vtz)
icsdata = cal.getText()
fpath = os.path.join(outputdir, zone.name + ".ics")
if not os.path.exists(os.path.dirname(fpath)):
os.makedirs(os.path.dirname(fpath))
with open(fpath, "w") as f:
f.write(icsdata)
if self.verbose:
print("Write path: %s" % (fpath,))
if links:
if windowsAliases is not None:
self.parseWindowsAliases(windowsAliases)
link_list = []
for linkTo, linkFrom in sorted(self.links.iteritems(), key=lambda x: x[0]):
# Check for existing output file
fromPath = os.path.join(outputdir, linkFrom + ".ics")
if not os.path.exists(fromPath):
print("Missing link from: %s to %s" % (linkFrom, linkTo,))
continue
with open(fromPath) as f:
icsdata = f.read()
icsdata = icsdata.replace(linkFrom, linkTo)
toPath = os.path.join(outputdir, linkTo + ".ics")
if not os.path.exists(os.path.dirname(toPath)):
os.makedirs(os.path.dirname(toPath))
with open(toPath, "w") as f:
f.write(icsdata)
if self.verbose:
print("Write link: %s" % (linkTo,))
link_list.append("%s\t%s" % (linkTo, linkFrom,))
# Generate link mapping file
linkPath = os.path.join(outputdir, "links.txt")
with open(linkPath, "w") as f:
f.write("\n".join(link_list))
示例2: vtimezones
# 需要导入模块: from pycalendar.icalendar.calendar import Calendar [as 别名]
# 或者: from pycalendar.icalendar.calendar.Calendar import getText [as 别名]
def vtimezones(self, minYear, maxYear=2018, filterzones=None):
"""
Generate iCalendar data for all VTIMEZONEs or just those specified
"""
cal = Calendar()
for zone in self.zones.itervalues():
if filterzones and zone.name not in filterzones:
continue
vtz = zone.vtimezone(cal, self.rules, minYear, maxYear)
cal.addComponent(vtz)
return cal.getText()