home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2010 November / maximum-cd-2010-11.iso / DiscContents / calibre-0.7.13.msi / file_771 (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2010-08-06  |  3.5 KB  |  109 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.         title = None if mi.title else 'Unknown'
  50.         title = title.replace(' ', '_')
  51.         au = mi.format_authors()
  52.         if not au:
  53.             au = 'Unknown'
  54.         
  55.         return '%s#%s%s' % (au, title, fileext)
  56.  
  57.     
  58.     def metadata_from_path(cls, path):
  59.         
  60.         def check_unicode(txt):
  61.             txt = txt.replace('_', ' ')
  62.             if not isinstance(txt, unicode):
  63.                 return txt.decode(sys.getfilesystemencoding(), 'replace')
  64.             return txt
  65.  
  66.         mi = cls.metadata_from_formats([
  67.             path])
  68.         if (mi.title == _('Unknown') or mi.authors == [
  69.             _('Unknown')]) and '#' in mi.title:
  70.             fn = os.path.splitext(os.path.basename(path))[0]
  71.             match = cls.JETBOOK_FILE_NAME_PATTERN.match(fn)
  72.             if match is not None:
  73.                 mi.title = check_unicode(match.group('title'))
  74.                 authors = string_to_authors(match.group('authors'))
  75.                 mi.authors = map(check_unicode, authors)
  76.             
  77.         
  78.         return mi
  79.  
  80.     metadata_from_path = classmethod(metadata_from_path)
  81.  
  82.  
  83. class MIBUK(USBMS):
  84.     name = 'MiBuk Wolder Device Interface'
  85.     description = _('Communicate with the MiBuk Wolder reader.')
  86.     author = 'Kovid Goyal'
  87.     supported_platforms = [
  88.         'windows',
  89.         'osx',
  90.         'linux']
  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.