home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 2.6)
-
- __license__ = 'GPL v3'
- __copyright__ = '2009, John Schember <john at nachtimwald.com>'
- __docformat__ = 'restructuredtext en'
- import re
- import os
- from calibre.devices.usbms.driver import USBMS
-
- def is_alex(device_info):
- if device_info[3] == u'Linux 2.6.28 with pxa3xx_u2d':
- pass
- return device_info[4] == u'Seleucia Disk'
-
-
- class N516(USBMS):
- name = 'N516 driver'
- gui_name = 'N516'
- description = _('Communicate with the Hanvon N520 eBook reader.')
- author = 'John Schember'
- supported_platforms = [
- 'windows',
- 'osx',
- 'linux']
- FORMATS = [
- 'epub',
- 'prc',
- 'html',
- 'pdf',
- 'txt']
- VENDOR_ID = [
- 1317]
- PRODUCT_ID = [
- 42149]
- BCD = [
- 803,
- 806,
- 807]
- VENDOR_NAME = 'INGENIC'
- WINDOWS_MAIN_MEM = '_FILE-STOR_GADGE'
- MAIN_MEMORY_VOLUME_LABEL = 'N520 Internal Memory'
- EBOOK_DIR_MAIN = 'e_book'
- SUPPORTS_SUB_DIRS = True
-
- def can_handle(self, device_info, debug = False):
- return not is_alex(device_info)
-
-
-
- class THEBOOK(N516):
- name = 'The Book driver'
- gui_name = 'The Book'
- description = _('Communicate with The Book reader.')
- author = 'Kovid Goyal'
- BCD = [
- 921]
- MAIN_MEMORY_VOLUME_LABEL = 'The Book Main Memory'
- EBOOK_DIR_MAIN = 'My books'
- WINDOWS_CARD_A_MEM = '_FILE-STOR_GADGE'
-
-
- class ALEX(N516):
- name = 'Alex driver'
- gui_name = 'SpringDesign Alex'
- description = _('Communicate with the SpringDesign Alex eBook reader.')
- author = 'Kovid Goyal'
- FORMATS = [
- 'epub',
- 'fb2',
- 'pdf']
- VENDOR_NAME = 'ALEX'
- WINDOWS_MAIN_MEM = 'READER'
- MAIN_MEMORY_VOLUME_LABEL = 'Alex Internal Memory'
- EBOOK_DIR_MAIN = 'eBooks'
- SUPPORTS_SUB_DIRS = False
- THUMBNAIL_HEIGHT = 120
-
- def can_handle(self, device_info, debug = False):
- return is_alex(device_info)
-
-
- def alex_cpath(self, file_abspath):
- base = os.path.dirname(file_abspath)
- name = os.path.splitext(os.path.basename(file_abspath))[0] + '.png'
- return os.path.join(base, 'covers', name)
-
-
- def upload_cover(self, path, filename, metadata, filepath):
- calibre_cover = calibre_cover
- import calibre.ebooks
- thumbnail = thumbnail
- import calibre.utils.magick.draw
- coverdata = getattr(metadata, 'thumbnail', None)
- if coverdata and coverdata[2]:
- cover = coverdata[2]
- else:
- cover = calibre_cover(metadata.get('title', _('Unknown')), metadata.get('authors', _('Unknown')))
- cover = thumbnail(cover, width = self.THUMBNAIL_HEIGHT, height = self.THUMBNAIL_HEIGHT, fmt = 'png')[-1]
- cpath = self.alex_cpath(os.path.join(path, filename))
- cdir = os.path.dirname(cpath)
- if not os.path.exists(cdir):
- os.makedirs(cdir)
-
-
- try:
- coverfile = _[1]
- coverfile.write(cover)
- finally:
- pass
-
-
-
- def delete_books(self, paths, end_session = True):
- for i, path in enumerate(paths):
- self.report_progress((i + 1) / float(len(paths)), _('Removing books from device...'))
- path = self.normalize_path(path)
- if os.path.exists(path):
- os.unlink(path)
-
-
- try:
- cpath = self.alex_cpath(path)
- if os.path.exists(cpath):
- os.remove(cpath)
- continue
- continue
-
-
- self.report_progress(1, _('Removing books from device...'))
-
-
-
- class AZBOOKA(ALEX):
- name = 'Azbooka driver'
- gui_name = 'Azbooka'
- description = _('Communicate with the Azbooka')
- VENDOR_NAME = 'LINUX'
- WINDOWS_MAIN_MEM = 'FILE-STOR_GADGET'
- MAIN_MEMORY_VOLUME_LABEL = 'Azbooka Internal Memory'
- EBOOK_DIR_MAIN = ''
- SUPPORTS_SUB_DIRS = True
-
- def can_handle(self, device_info, debug = False):
- return not is_alex(device_info)
-
-
- def upload_cover(self, path, filename, metadata, filepath):
- pass
-
-
-
- class EB511(USBMS):
- name = 'Elonex EB 511 driver'
- gui_name = 'EB 511'
- description = _('Communicate with the Elonex EB 511 eBook reader.')
- author = 'Kovid Goyal'
- supported_platforms = [
- 'windows',
- 'osx',
- 'linux']
- FORMATS = [
- 'epub',
- 'html',
- 'pdf',
- 'txt']
- VENDOR_ID = [
- 1118]
- PRODUCT_ID = [
- 65535]
- BCD = [
- 0]
- MAIN_MEMORY_VOLUME_LABEL = 'EB 511 Internal Memory'
- EBOOK_DIR_MAIN = 'e_book'
- SUPPORTS_SUB_DIRS = True
- OSX_MAIN_MEM_VOL_PAT = re.compile('/eReader')
-
-