本文整理汇总了Python中writer.Writer.end方法的典型用法代码示例。如果您正苦于以下问题:Python Writer.end方法的具体用法?Python Writer.end怎么用?Python Writer.end使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类writer.Writer
的用法示例。
在下文中一共展示了Writer.end方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from writer import Writer [as 别名]
# 或者: from writer.Writer import end [as 别名]
def main():
print "Welcome to draugiem.lv message downloader "
sys.stdout.write("Email: ")
sys.stdout.flush()
email = raw_input()
password = getpass.getpass()
try:
downloader = MessageDownloader(email, password)
except DraugiemException:
print "invalid username/password"
sys.exit(1)
def progress_show(current, total):
sys.stdout.write("%3d of %d\r" % (current, total))
sys.stdout.flush()
print "[1/4] downloading inbox"
downloader.get_messages(type = 'in', progress_callback = progress_show)
print "[2/4] downloading outbox"
downloader.get_messages(type = 'out', progress_callback = progress_show)
print "[3/4] sorting messages"
msgs = downloader.get_all_messages()
sys.stdout.write("Enter path: ")
sys.stdout.flush()
path = raw_input()
if not os.path.exists(path):
os.mkdir(path)
print "[4/4] writing"
for user in msgs:
w = Writer(os.path.join(path, "%s.html" % (downloader.get_user_info(user).replace("/", ""))))
w.start(downloader.users[user])
for item in msgs[user]:
w.write(item)
w.end()