Exemplo n.º 1
0
 def select_import_folder(self):
     path = choose_dir(self, 'choose-export-folder-for-import', _('Select folder with exported data'))
     if path is None:
         return
     try:
         self.importer = Importer(path)
     except Exception as e:
         import traceback
         return error_dialog(self, _('Not valid'), _(
             'The folder {0} is not valid: {1}').format(path, as_unicode(e)), det_msg=traceback.format_exc(), show=True)
     self.setup_select_libraries_panel()
     self.import_panel.stack.setCurrentIndex(1)
Exemplo n.º 2
0
 def test_export_import(self):
     from calibre.db.cache import import_library
     from calibre.utils.exim import Exporter, Importer
     cache = self.init_cache()
     for part_size in (1 << 30, 100, 1):
         with TemporaryDirectory('export_lib') as tdir, TemporaryDirectory('import_lib') as idir:
             exporter = Exporter(tdir, part_size=part_size)
             cache.export_library('l', exporter)
             exporter.commit()
             importer = Importer(tdir)
             ic = import_library('l', importer, idir)
             self.assertEqual(cache.all_book_ids(), ic.all_book_ids())
             for book_id in cache.all_book_ids():
                 self.assertEqual(cache.cover(book_id), ic.cover(book_id), 'Covers not identical for book: %d' % book_id)
                 for fmt in cache.formats(book_id):
                     self.assertEqual(cache.format(book_id, fmt), ic.format(book_id, fmt))
                     self.assertEqual(cache.format_metadata(book_id, fmt)['mtime'], cache.format_metadata(book_id, fmt)['mtime'])
Exemplo n.º 3
0
 def select_import_folder(self):
     path = choose_dir(self, 'choose-export-folder-for-import', _('Select folder with exported data'))
     if path is None:
         return
     if not question_dialog(self, _('Are you sure?'), _(
         'Importing calibre data means all libraries, settings, plugins, etc will be imported. This is'
         ' a security risk, only proceed if the data you are importing was previously generated by you, using the calibre'
         ' export functionality.'
         )):
         return
     try:
         self.importer = Importer(path)
     except Exception as e:
         import traceback
         return error_dialog(self, _('Not valid'), _(
             'The folder {0} is not valid: {1}').format(path, as_unicode(e)), det_msg=traceback.format_exc(), show=True)
     self.setup_select_libraries_panel()
     self.import_panel.stack.setCurrentIndex(1)