當前位置: 首頁>>代碼示例>>Python>>正文


Python AuthorSortEdit.auto_generate方法代碼示例

本文整理匯總了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)
開發者ID:JapaChin,項目名稱:calibre,代碼行數:70,代碼來源:single.py

示例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
開發者ID:GaryMMugford,項目名稱:calibre,代碼行數:70,代碼來源:single.py


注:本文中的calibre.gui2.metadata.basic_widgets.AuthorSortEdit.auto_generate方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。