~ubuntu-branches/debian/wheezy/calibre/wheezy

« back to all changes in this revision

Viewing changes to src/calibre/devices/kindle/driver.py

  • Committer: Package Import Robot
  • Author(s): Martin Pitt
  • Date: 2012-01-07 11:22:54 UTC
  • mfrom: (29.4.10 precise)
  • Revision ID: package-import@ubuntu.com-20120107112254-n1syr437o46ds802
Tags: 0.8.34+dfsg-1
* New upstream version. (Closes: #654751)
* debian/rules: Do not install calibre copy of chardet; instead, add
  build/binary python-chardet dependency.
* Add disable_plugins.py: Disable plugin dialog. It uses a totally
  non-authenticated and non-trusted way of installing arbitrary code.
  (Closes: #640026)
* debian/rules: Install with POSIX locale, to avoid installing translated
  manpages into the standard locations. (Closes: #646674)

Show diffs side-by-side

added added

removed removed

Lines of Context:
284
284
 
285
285
class KINDLE2(KINDLE):
286
286
 
287
 
    name           = 'Kindle 2/3 Device Interface'
288
 
    description    = _('Communicate with the Kindle 2/3 eBook reader.')
 
287
    name           = 'Kindle 2/3/4/Touch Device Interface'
 
288
    description    = _('Communicate with the Kindle 2/3/4/Touch eBook reader.')
289
289
 
290
290
    FORMATS        = KINDLE.FORMATS + ['pdf', 'azw4', 'pobi']
291
 
    DELETE_EXTS    = KINDLE.DELETE_EXTS
 
291
    DELETE_EXTS    = KINDLE.DELETE_EXTS + ['.mbp1', '.mbs', '.sdr']
292
292
 
293
293
    PRODUCT_ID = [0x0002, 0x0004]
294
294
    BCD        = [0x0100]
347
347
                if h in path_map:
348
348
                    book.device_collections = list(sorted(path_map[h]))
349
349
 
 
350
    # Detect if the product family needs .apnx files uploaded to sidecar folder
 
351
    def post_open_callback(self):
 
352
        product_id = self.device_being_opened[1]
 
353
        self.sidecar_apnx = False
 
354
        if product_id > 0x3:
 
355
            # Check if we need to put the apnx into a sidecar dir
 
356
            for _, dirnames, _ in os.walk(self._main_prefix):
 
357
                for x in dirnames:
 
358
                    if x.endswith('.sdr'):
 
359
                        self.sidecar_apnx = True
 
360
                        return
 
361
 
350
362
    def upload_cover(self, path, filename, metadata, filepath):
351
363
        '''
352
364
        Hijacking this function to write the apnx file.
358
370
        if os.path.splitext(filepath.lower())[1] not in ('.azw', '.mobi', '.prc'):
359
371
            return
360
372
 
 
373
        # Create the sidecar folder if necessary
 
374
        if (self.sidecar_apnx):
 
375
            path = os.path.join(os.path.dirname(filepath), filename+".sdr")
 
376
 
 
377
            if not os.path.exists(path):
 
378
                os.makedirs(path)
 
379
 
361
380
        apnx_path = '%s.apnx' % os.path.join(path, filename)
362
381
        apnx_builder = APNXBuilder()
363
382
        try: