本文整理汇总了Python中calibre.db.legacy.LibraryDatabase.get_top_level_move_items方法的典型用法代码示例。如果您正苦于以下问题:Python LibraryDatabase.get_top_level_move_items方法的具体用法?Python LibraryDatabase.get_top_level_move_items怎么用?Python LibraryDatabase.get_top_level_move_items使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类calibre.db.legacy.LibraryDatabase
的用法示例。
在下文中一共展示了LibraryDatabase.get_top_level_move_items方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: move_library
# 需要导入模块: from calibre.db.legacy import LibraryDatabase [as 别名]
# 或者: from calibre.db.legacy.LibraryDatabase import get_top_level_move_items [as 别名]
def move_library(oldloc, newloc, parent, callback_on_complete):
from calibre.db.legacy import LibraryDatabase
callback = Callback(callback_on_complete)
try:
if not os.path.exists(os.path.join(newloc, 'metadata.db')):
if oldloc and os.access(os.path.join(oldloc, 'metadata.db'), os.R_OK):
# Move old library to new location
try:
db = LibraryDatabase(oldloc)
except:
return move_library(None, newloc, parent,
callback)
else:
rq = Queue()
m = MoveLibrary(oldloc, newloc,
len(db.get_top_level_move_items()[0]), rq)
global _mm
_mm = MoveMonitor(m, rq, callback, parent)
return
else:
# Create new library at new location
db = LibraryDatabase(newloc)
callback(newloc)
return
# Try to load existing library at new location
try:
LibraryDatabase(newloc)
except Exception as err:
det = traceback.format_exc()
error_dialog(parent, _('Invalid database'),
_('<p>An invalid library already exists at '
'%(loc)s, delete it before trying to move the '
'existing library.<br>Error: %(err)s')%dict(loc=newloc,
err=str(err)), det, show=True)
callback(None)
return
else:
callback(newloc)
return
except Exception as err:
det = traceback.format_exc()
error_dialog(parent, _('Could not move library'),
unicode(err), det, show=True)
callback(None)