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

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. __license__ = 'GPL v3'
  5. __copyright__ = '2009, James Ralston <jralston at mindspring.com>'
  6. __docformat__ = 'restructuredtext en'
  7. import os
  8. import re
  9. import sys
  10. from calibre.devices.usbms.driver import USBMS
  11. from calibre.ebooks.metadata import string_to_authors
  12.  
  13. class JETBOOK(USBMS):
  14.     name = 'Ectaco JetBook Device Interface'
  15.     description = _('Communicate with the JetBook eBook reader.')
  16.     author = 'James Ralston'
  17.     supported_platforms = [
  18.         'windows',
  19.         'osx',
  20.         'linux']
  21.     FORMATS = [
  22.         'epub',
  23.         'mobi',
  24.         'prc',
  25.         'fb2',
  26.         'txt',
  27.         'rtf',
  28.         'pdf']
  29.     VENDOR_ID = [
  30.         1317]
  31.     PRODUCT_ID = [
  32.         42149]
  33.     BCD = [
  34.         788]
  35.     VENDOR_NAME = 'LINUX'
  36.     WINDOWS_MAIN_MEM = 'EBOOK'
  37.     WINDOWS_CARD_A_MEM = 'EBOOK'
  38.     OSX_MAIN_MEM = 'Linux ebook Media'
  39.     OSX_CARD_A_MEM = 'Linux ebook Media'
  40.     MAIN_MEMORY_VOLUME_LABEL = 'Jetbook Main Memory'
  41.     STORAGE_CARD_VOLUME_LABEL = 'Jetbook Storage Card'
  42.     EBOOK_DIR_MAIN = 'Books'
  43.     EBOOK_DIR_CARD_A = 'Books'
  44.     SUPPORTS_SUB_DIRS = True
  45.     JETBOOK_FILE_NAME_PATTERN = re.compile('(?P<authors>.+)#(?P<title>.+)')
  46.     
  47.     def filename_callback(self, fname, mi):
  48.         fileext = os.path.splitext(os.path.basename(fname))[1]
  49.         if fileext.lower() not in ('txt', 'pdf', 'fb2'):
  50.             return fname
  51.         title = fileext.lower() not in ('txt', 'pdf', 'fb2') if mi.title else 'Unknown'
  52.         title = title.replace(' ', '_')
  53.         au = mi.format_authors()
  54.         if not au:
  55.             au = 'Unknown'
  56.         
  57.         return '%s#%s%s' % (au, title, fileext)
  58.  
  59.     
  60.     def metadata_from_path(cls, path):
  61.         
  62.         def check_unicode(txt):
  63.             txt = txt.replace('_', ' ')
  64.             if not isinstance(txt, unicode):
  65.                 return txt.decode(sys.getfilesystemencoding(), 'replace')
  66.             return txt
  67.  
  68.         mi = cls.metadata_from_formats([
  69.             path])
  70.         if (mi.title == _('Unknown') or mi.authors == [
  71.             _('Unknown')]) and '#' in mi.title:
  72.             fn = os.path.splitext(os.path.basename(path))[0]
  73.             match = cls.JETBOOK_FILE_NAME_PATTERN.match(fn)
  74.             if match is not None:
  75.                 mi.title = check_unicode(match.group('title'))
  76.                 authors = string_to_authors(match.group('authors'))
  77.                 mi.authors = map(check_unicode, authors)
  78.             
  79.         
  80.         return mi
  81.  
  82.     metadata_from_path = classmethod(metadata_from_path)
  83.  
  84.  
  85. class MIBUK(USBMS):
  86.     name = 'MiBuk Wolder Device Interface'
  87.     description = _('Communicate with the MiBuk Wolder reader.')
  88.     author = 'Kovid Goyal'
  89.     supported_platforms = [
  90.         'windows']
  91.     FORMATS = [
  92.         'epub',
  93.         'mobi',
  94.         'prc',
  95.         'fb2',
  96.         'txt',
  97.         'rtf',
  98.         'pdf']
  99.     VENDOR_ID = [
  100.         1317]
  101.     PRODUCT_ID = [
  102.         42149]
  103.     BCD = [
  104.         788]
  105.     SUPPORTS_SUB_DIRS = True
  106.     VENDOR_NAME = 'LINUX'
  107.     WINDOWS_MAIN_MEM = 'WOLDERMIBUK'
  108.  
  109.  
  110. class JETBOOK_MINI(USBMS):
  111.     FORMATS = [
  112.         'fb2',
  113.         'txt']
  114.     gui_name = 'JetBook Mini'
  115.     name = 'JetBook Mini Device Interface'
  116.     description = _('Communicate with the JetBook Mini reader.')
  117.     author = 'Kovid Goyal'
  118.     VENDOR_ID = [
  119.         1208]
  120.     PRODUCT_ID = [
  121.         1287]
  122.     BCD = [
  123.         256]
  124.     VENDOR_NAME = 'ECTACO'
  125.     WINDOWS_MAIN_MEM = ''
  126.     MAIN_MEMORY_VOLUME_LABEL = 'Jetbook Mini'
  127.     SUPPORTS_SUB_DIRS = True
  128.  
  129.