本文整理汇总了Python中calibre.gui2.metadata.basic_widgets.AuthorSortEdit.auto_generate方法的典型用法代码示例。如果您正苦于以下问题:Python AuthorSortEdit.auto_generate方法的具体用法?Python AuthorSortEdit.auto_generate怎么用?Python AuthorSortEdit.auto_generate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类calibre.gui2.metadata.basic_widgets.AuthorSortEdit
的用法示例。
在下文中一共展示了AuthorSortEdit.auto_generate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MetadataSingleDialogBase
# 需要导入模块: from calibre.gui2.metadata.basic_widgets import AuthorSortEdit [as 别名]
# 或者: from calibre.gui2.metadata.basic_widgets.AuthorSortEdit import auto_generate [as 别名]
#.........这里部分代码省略.........
def copy_fmt(self, fmt, f):
self.db.copy_format_to(self.book_id, fmt, f, index_is_id=True)
def do_layout(self):
raise NotImplementedError()
def __call__(self, id_):
self.book_id = id_
self.books_to_refresh = set([])
self.metadata_before_fetch = None
for widget in self.basic_metadata_widgets:
widget.initialize(self.db, id_)
for widget in getattr(self, 'custom_metadata_widgets', []):
widget.initialize(id_)
if callable(self.set_current_callback):
self.set_current_callback(id_)
# Commented out as it doesn't play nice with Next, Prev buttons
# self.fetch_metadata_button.setFocus(Qt.OtherFocusReason)
# Miscellaneous interaction methods {{{
def update_window_title(self, *args):
title = self.title.current_val
if len(title) > 50:
title = title[:50] + u'\u2026'
self.setWindowTitle(BASE_TITLE + ' - ' +
title + ' - ' +
_(' [%(num)d of %(tot)d]')%dict(num=self.current_row+1,
tot=len(self.row_list)))
def swap_title_author(self, *args):
title = self.title.current_val
self.title.current_val = authors_to_string(self.authors.current_val)
self.authors.current_val = string_to_authors(title)
self.title_sort.auto_generate()
self.author_sort.auto_generate()
def tags_editor(self, *args):
self.tags.edit(self.db, self.book_id)
def metadata_from_format(self, *args):
mi, ext = self.formats_manager.get_selected_format_metadata(self.db,
self.book_id)
if mi is not None:
self.update_from_mi(mi)
def get_pdf_cover(self):
pdfpath = self.formats_manager.get_format_path(self.db, self.book_id,
'pdf')
from calibre.gui2.metadata.pdf_covers import PDFCovers
d = PDFCovers(pdfpath, parent=self)
if d.exec_() == d.Accepted:
cpath = d.cover_path
if cpath:
with open(cpath, 'rb') as f:
self.update_cover(f.read(), 'PDF')
d.cleanup()
def cover_from_format(self, *args):
ext = self.formats_manager.get_selected_format()
if ext is None:
return
if ext == 'pdf':
return self.get_pdf_cover()
try:
mi, ext = self.formats_manager.get_selected_format_metadata(self.db,
self.book_id)
示例2: MetadataSingleDialogBase
# 需要导入模块: from calibre.gui2.metadata.basic_widgets import AuthorSortEdit [as 别名]
# 或者: from calibre.gui2.metadata.basic_widgets.AuthorSortEdit import auto_generate [as 别名]
#.........这里部分代码省略.........
def do_layout(self):
raise NotImplementedError()
def __call__(self, id_):
self.book_id = id_
self.books_to_refresh = set([])
for widget in self.basic_metadata_widgets:
widget.initialize(self.db, id_)
for widget in getattr(self, "custom_metadata_widgets", []):
widget.initialize(id_)
if callable(self.set_current_callback):
self.set_current_callback(id_)
# Commented out as it doesn't play nice with Next, Prev buttons
# self.fetch_metadata_button.setFocus(Qt.OtherFocusReason)
# Miscellaneous interaction methods {{{
def update_window_title(self, *args):
title = self.title.current_val
if len(title) > 50:
title = title[:50] + "\u2026"
self.setWindowTitle(
BASE_TITLE
+ " - "
+ title
+ " - "
+ _(" [%(num)d of %(tot)d]") % dict(num=self.current_row + 1, tot=len(self.row_list))
)
def swap_title_author(self, *args):
title = self.title.current_val
self.title.current_val = authors_to_string(self.authors.current_val)
self.authors.current_val = string_to_authors(title)
self.title_sort.auto_generate()
self.author_sort.auto_generate()
def tags_editor(self, *args):
self.tags.edit(self.db, self.book_id)
def metadata_from_format(self, *args):
mi, ext = self.formats_manager.get_selected_format_metadata(self.db, self.book_id)
if mi is not None:
self.update_from_mi(mi)
def get_pdf_cover(self):
pdfpath = self.formats_manager.get_format_path(self.db, self.book_id, "pdf")
from calibre.gui2.metadata.pdf_covers import PDFCovers
d = PDFCovers(pdfpath, parent=self)
if d.exec_() == d.Accepted:
cpath = d.cover_path
if cpath:
with open(cpath, "rb") as f:
self.update_cover(f.read(), "PDF")
d.cleanup()
def cover_from_format(self, *args):
ext = self.formats_manager.get_selected_format()
if ext is None:
return
if ext == "pdf":
return self.get_pdf_cover()
try:
mi, ext = self.formats_manager.get_selected_format_metadata(self.db, self.book_id)
except (IOError, OSError) as err:
if getattr(err, "errno", None) == errno.EACCES: # Permission denied