本文整理匯總了Python中importer.Importer.load_table方法的典型用法代碼示例。如果您正苦於以下問題:Python Importer.load_table方法的具體用法?Python Importer.load_table怎麽用?Python Importer.load_table使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類importer.Importer
的用法示例。
在下文中一共展示了Importer.load_table方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: ImportDatabase
# 需要導入模塊: from importer import Importer [as 別名]
# 或者: from importer.Importer import load_table [as 別名]
def ImportDatabase(self):
"""Import an old-style .db qwitter database, or .session file into the current session's storage."""
def import_buffer (tablename, buffername):
table = new.load_table(tablename)
newtable = new.convert_table(table)
buf = self.session.get_buffer_by_name(buffername)
buf.storage.extend(newtable)
buf.storage.sort(key=lambda a: calendar.timegm(rfc822.parsedate(a['created_at'])))
buf.storage = misc.RemoveDuplicates(buf.storage, lambda x: x['id'])
f = wx.Frame(None, wx.ID_ANY, "FileDialog")
dlg = wx.FileDialog(f, message="Select Database", defaultDir=paths.data_path(), wildcard="Session files (*.session)|*.session|Qwitter Databases (*.DB)|*.db")
f.Raise()
if dlg.ShowModal() == wx.ID_OK:
filename = dlg.GetPath()
dlg.Destroy()
f.Destroy()
else:
output.speak(_("Canceled"), True)
dlg.Destroy()
f.Destroy()
return
if filename.lower().endswith('.db'):
new = Importer(filename)
home = new.load_table("tweets")
directs = new.load_table("directs")
mentions = new.load_table("replies")
sent = new.load_table("sent")
total = len(home) + len(directs) + len(mentions) + len(sent)
yesno = wx.MessageBox(_("Are you sure you want to import %d items from old database?") % total, _("Are you sure?"), style=wx.YES|wx.NO)
if yesno == wx.YES:
output.speak(_("Importing, please wait."), True)
else:
return output.speak(_("Canceled."), True)
for i in [("tweets", "Home"), ("replies", "Mentions"), ("directs", "Direct Messages"), ("sent", "Sent")]:
import_buffer(*i)
elif filename.lower().endswith('.session'):
try:
new = SessionImporter(filename)
except TypeError:
return output.speak(_("Session type mismatch."))
new.do_import()
wx.MessageBox(_("Import completed successfully."), _("Import complete."))