本文整理汇总了Python中twistedcaldav.ical.Component.allFromStream方法的典型用法代码示例。如果您正苦于以下问题:Python Component.allFromStream方法的具体用法?Python Component.allFromStream怎么用?Python Component.allFromStream使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twistedcaldav.ical.Component
的用法示例。
在下文中一共展示了Component.allFromStream方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: doWork
# 需要导入模块: from twistedcaldav.ical import Component [as 别名]
# 或者: from twistedcaldav.ical.Component import allFromStream [as 别名]
def doWork(self):
"""
Do the export, stopping the reactor when done.
"""
try:
if self.options.inputDirectoryName:
dirname = self.options.inputDirectoryName
if not os.path.exists(dirname):
sys.stderr.write(
"Directory does not exist: {}\n".format(dirname)
)
sys.exit(1)
for filename in os.listdir(dirname):
fullpath = os.path.join(dirname, filename)
print("Importing {}".format(fullpath))
fileobj = open(fullpath, 'r')
component = Component.allFromStream(fileobj)
fileobj.close()
yield importCollectionComponent(self.store, component)
else:
try:
input = self.options.openInput()
except IOError, e:
sys.stderr.write(
"Unable to open input file for reading: %s\n" % (e)
)
sys.exit(1)
component = Component.allFromStream(input)
input.close()
yield importCollectionComponent(self.store, component)
except:
log.failure("doWork()")