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

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. __license__ = 'GPL v3'
  5. __copyright__ = '2009, John Schember <john at nachtimwald.com>'
  6. __docformat__ = 'restructuredtext en'
  7. import re
  8. import os
  9. from calibre.devices.usbms.driver import USBMS
  10.  
  11. def is_alex(device_info):
  12.     if device_info[3] == u'Linux 2.6.28 with pxa3xx_u2d':
  13.         pass
  14.     return device_info[4] == u'Seleucia Disk'
  15.  
  16.  
  17. class N516(USBMS):
  18.     name = 'N516 driver'
  19.     gui_name = 'N516'
  20.     description = _('Communicate with the Hanvon N520 eBook reader.')
  21.     author = 'John Schember'
  22.     supported_platforms = [
  23.         'windows',
  24.         'osx',
  25.         'linux']
  26.     FORMATS = [
  27.         'epub',
  28.         'prc',
  29.         'html',
  30.         'pdf',
  31.         'txt']
  32.     VENDOR_ID = [
  33.         1317]
  34.     PRODUCT_ID = [
  35.         42149]
  36.     BCD = [
  37.         803,
  38.         806,
  39.         807]
  40.     VENDOR_NAME = 'INGENIC'
  41.     WINDOWS_MAIN_MEM = '_FILE-STOR_GADGE'
  42.     MAIN_MEMORY_VOLUME_LABEL = 'N520 Internal Memory'
  43.     EBOOK_DIR_MAIN = 'e_book'
  44.     SUPPORTS_SUB_DIRS = True
  45.     
  46.     def can_handle(self, device_info, debug = False):
  47.         return not is_alex(device_info)
  48.  
  49.  
  50.  
  51. class THEBOOK(N516):
  52.     name = 'The Book driver'
  53.     gui_name = 'The Book'
  54.     description = _('Communicate with The Book reader.')
  55.     author = 'Kovid Goyal'
  56.     BCD = [
  57.         921]
  58.     MAIN_MEMORY_VOLUME_LABEL = 'The Book Main Memory'
  59.     EBOOK_DIR_MAIN = 'My books'
  60.     WINDOWS_CARD_A_MEM = '_FILE-STOR_GADGE'
  61.  
  62.  
  63. class ALEX(N516):
  64.     name = 'Alex driver'
  65.     gui_name = 'SpringDesign Alex'
  66.     description = _('Communicate with the SpringDesign Alex eBook reader.')
  67.     author = 'Kovid Goyal'
  68.     FORMATS = [
  69.         'epub',
  70.         'fb2',
  71.         'pdf']
  72.     VENDOR_NAME = 'ALEX'
  73.     WINDOWS_MAIN_MEM = 'READER'
  74.     MAIN_MEMORY_VOLUME_LABEL = 'Alex Internal Memory'
  75.     EBOOK_DIR_MAIN = 'eBooks'
  76.     SUPPORTS_SUB_DIRS = False
  77.     THUMBNAIL_HEIGHT = 120
  78.     
  79.     def can_handle(self, device_info, debug = False):
  80.         return is_alex(device_info)
  81.  
  82.     
  83.     def alex_cpath(self, file_abspath):
  84.         base = os.path.dirname(file_abspath)
  85.         name = os.path.splitext(os.path.basename(file_abspath))[0] + '.png'
  86.         return os.path.join(base, 'covers', name)
  87.  
  88.     
  89.     def upload_cover(self, path, filename, metadata, filepath):
  90.         calibre_cover = calibre_cover
  91.         import calibre.ebooks
  92.         thumbnail = thumbnail
  93.         import calibre.utils.magick.draw
  94.         coverdata = getattr(metadata, 'thumbnail', None)
  95.         if coverdata and coverdata[2]:
  96.             cover = coverdata[2]
  97.         else:
  98.             cover = calibre_cover(metadata.get('title', _('Unknown')), metadata.get('authors', _('Unknown')))
  99.         cover = thumbnail(cover, width = self.THUMBNAIL_HEIGHT, height = self.THUMBNAIL_HEIGHT, fmt = 'png')[-1]
  100.         cpath = self.alex_cpath(os.path.join(path, filename))
  101.         cdir = os.path.dirname(cpath)
  102.         if not os.path.exists(cdir):
  103.             os.makedirs(cdir)
  104.         
  105.         
  106.         try:
  107.             coverfile = _[1]
  108.             coverfile.write(cover)
  109.         finally:
  110.             pass
  111.  
  112.  
  113.     
  114.     def delete_books(self, paths, end_session = True):
  115.         for i, path in enumerate(paths):
  116.             self.report_progress((i + 1) / float(len(paths)), _('Removing books from device...'))
  117.             path = self.normalize_path(path)
  118.             if os.path.exists(path):
  119.                 os.unlink(path)
  120.             
  121.             
  122.             try:
  123.                 cpath = self.alex_cpath(path)
  124.                 if os.path.exists(cpath):
  125.                     os.remove(cpath)
  126.             continue
  127.             continue
  128.  
  129.         
  130.         self.report_progress(1, _('Removing books from device...'))
  131.  
  132.  
  133.  
  134. class AZBOOKA(ALEX):
  135.     name = 'Azbooka driver'
  136.     gui_name = 'Azbooka'
  137.     description = _('Communicate with the Azbooka')
  138.     VENDOR_NAME = 'LINUX'
  139.     WINDOWS_MAIN_MEM = 'FILE-STOR_GADGET'
  140.     MAIN_MEMORY_VOLUME_LABEL = 'Azbooka Internal Memory'
  141.     EBOOK_DIR_MAIN = ''
  142.     SUPPORTS_SUB_DIRS = True
  143.     
  144.     def can_handle(self, device_info, debug = False):
  145.         return not is_alex(device_info)
  146.  
  147.     
  148.     def upload_cover(self, path, filename, metadata, filepath):
  149.         pass
  150.  
  151.  
  152.  
  153. class EB511(USBMS):
  154.     name = 'Elonex EB 511 driver'
  155.     gui_name = 'EB 511'
  156.     description = _('Communicate with the Elonex EB 511 eBook reader.')
  157.     author = 'Kovid Goyal'
  158.     supported_platforms = [
  159.         'windows',
  160.         'osx',
  161.         'linux']
  162.     FORMATS = [
  163.         'epub',
  164.         'html',
  165.         'pdf',
  166.         'txt']
  167.     VENDOR_ID = [
  168.         1118]
  169.     PRODUCT_ID = [
  170.         65535]
  171.     BCD = [
  172.         0]
  173.     MAIN_MEMORY_VOLUME_LABEL = 'EB 511 Internal Memory'
  174.     EBOOK_DIR_MAIN = 'e_book'
  175.     SUPPORTS_SUB_DIRS = True
  176.     OSX_MAIN_MEM_VOL_PAT = re.compile('/eReader')
  177.  
  178.