home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2011 January / maximum-cd-2011-01.iso / DiscContents / calibre-0.7.26.msi / file_1253 (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2010-10-31  |  1.9 KB  |  46 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. __license__ = 'GPL v3'
  5. __copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
  6. __docformat__ = 'restructuredtext en'
  7. from PyQt4.Qt import QDialog, QApplication
  8. from calibre.gui2.dialogs.add_from_isbn_ui import Ui_Dialog
  9. from calibre.ebooks.metadata import check_isbn
  10.  
  11. class AddFromISBN(QDialog, Ui_Dialog):
  12.     
  13.     def __init__(self, parent = None):
  14.         QDialog.__init__(self, parent)
  15.         self.setupUi(self)
  16.         self.isbns = []
  17.         self.paste_button.clicked.connect(self.paste)
  18.  
  19.     
  20.     def paste(self, *args):
  21.         app = QApplication.instance()
  22.         c = app.clipboard()
  23.         txt = unicode(c.text()).strip()
  24.         if txt:
  25.             old = unicode(self.isbn_box.toPlainText()).strip()
  26.             new = old + '\n' + txt
  27.             self.isbn_box.setPlainText(new)
  28.         
  29.  
  30.     
  31.     def accept(self, *args):
  32.         for line in unicode(self.isbn_box.toPlainText()).strip().splitlines():
  33.             if line:
  34.                 isbn = check_isbn(line)
  35.                 if isbn is not None:
  36.                     isbn = isbn.upper()
  37.                     if isbn not in self.isbns:
  38.                         self.isbns.append(isbn)
  39.                     
  40.                 
  41.             isbn is not None
  42.         
  43.         QDialog.accept(self, *args)
  44.  
  45.  
  46.