Esempio n. 1
0
    def duplicates(self):
        for i in xrange(self.dup_list.topLevelItemCount()):
            x = self.dup_list.topLevelItem(i)
            if x.checkState(0) == Qt.Checked:
                yield x.data(0, Qt.UserRole)

    @property
    def as_text(self):
        entries = []
        for i in xrange(self.dup_list.topLevelItemCount()):
            x = self.dup_list.topLevelItem(i)
            check = '✓' if x.checkState(0) == Qt.Checked else '✗'
            title = '%s %s' % (check, unicode(x.text(0)))
            dups = []
            for child in (x.child(j) for j in xrange(x.childCount())):
                dups.append('\t' + unicode(child.text(0)))
            entries.append(title + '\n' + '\n'.join(dups))
        return '\n\n'.join(entries)


if __name__ == '__main__':
    from calibre.ebooks.metadata.book.base import Metadata as M
    from calibre.library import db

    app = QApplication([])
    db = db()
    d = DuplicatesQuestion(db, [(M('Life of Pi', ['Yann Martel']), None, None),
                            (M('Heirs of the blade', ['Adrian Tchaikovsky']), None, None)])
    print (tuple(d.duplicates))

Esempio n. 2
0
                ]
                add_child(
                    ta %
                    dict(title=db.title(book_id, index_is_id=True),
                         author=authors_to_string(aut),
                         formats=db.formats(
                             book_id, index_is_id=True, verify_formats=False)))
            add_child('')

            yield item

    @property
    def duplicates(self):
        for i in xrange(self.dup_list.topLevelItemCount()):
            x = self.dup_list.topLevelItem(i)
            if x.checkState(0) == Qt.Checked:
                yield x.data(0, Qt.UserRole).toPyObject()


if __name__ == '__main__':
    from PyQt4.Qt import QApplication
    from calibre.ebooks.metadata.book.base import Metadata as M
    from calibre.library import db

    app = QApplication([])
    db = db()
    d = DuplicatesQuestion(
        db, [(M('Life of Pi', ['Yann Martel']), None, None),
             (M('Heirs of the blade', ['Adrian Tchaikovsky']), None, None)])
    print(tuple(d.duplicates))