def create_db(self, library_path): from calibre.library.database2 import LibraryDatabase2 if LibraryDatabase2.exists_at(library_path): raise ValueError('A library already exists at %r'%library_path) src = os.path.join(os.path.dirname(__file__), 'metadata.db') db = os.path.join(library_path, 'metadata.db') shutil.copyfile(src, db) return db
def create_db(self, library_path): from calibre.library.database2 import LibraryDatabase2 if LibraryDatabase2.exists_at(library_path): raise ValueError('A library already exists at %r' % library_path) src = os.path.join(os.path.dirname(__file__), 'metadata.db') db = os.path.join(library_path, 'metadata.db') shutil.copyfile(src, db) return db
def accept(self): newloc = unicode(self.loc.text()) if not LibraryDatabase2.exists_at(newloc): error_dialog(self, _('No library found'), _('No existing calibre library found at %s')%newloc, show=True) return self.stats.rename(self.location, newloc) self.newloc = newloc QDialog.accept(self)
def accept(self): newloc = unicode(self.loc.text()) if not LibraryDatabase2.exists_at(newloc): error_dialog(self, _('No library found'), _('No existing calibre library found at %s') % newloc, show=True) return self.stats.rename(self.location, newloc) self.newloc = newloc QDialog.accept(self)
def create_db(self, library_path): from calibre.library.database2 import LibraryDatabase2 if LibraryDatabase2.exists_at(library_path): raise ValueError('A library already exists at %r' % library_path) src = os.path.join(os.path.dirname(__file__), 'metadata.db') dest = os.path.join(library_path, 'metadata.db') shutil.copyfile(src, dest) db = LibraryDatabase2(library_path) db.set_cover(1, I('lt.png', data=True)) db.set_cover(2, I('polish.png', data=True)) db.add_format(1, 'FMT1', BytesIO(b'book1fmt1'), index_is_id=True) db.add_format(1, 'FMT2', BytesIO(b'book1fmt2'), index_is_id=True) db.add_format(2, 'FMT1', BytesIO(b'book2fmt1'), index_is_id=True) db.conn.close() return dest
def create_db(self, library_path): from calibre.library.database2 import LibraryDatabase2 if LibraryDatabase2.exists_at(library_path): raise ValueError('A library already exists at %r'%library_path) src = os.path.join(os.path.dirname(__file__), 'metadata.db') dest = os.path.join(library_path, 'metadata.db') shutil.copyfile(src, dest) db = LibraryDatabase2(library_path) db.set_cover(1, I('lt.png', data=True)) db.set_cover(2, I('polish.png', data=True)) db.add_format(1, 'FMT1', BytesIO(b'book1fmt1'), index_is_id=True) db.add_format(1, 'FMT2', BytesIO(b'book1fmt2'), index_is_id=True) db.add_format(2, 'FMT1', BytesIO(b'book2fmt1'), index_is_id=True) db.conn.close() return dest
def create_db(self, library_path): from calibre.library.database2 import LibraryDatabase2 if LibraryDatabase2.exists_at(library_path): raise ValueError("A library already exists at %r" % library_path) src = os.path.join(os.path.dirname(__file__), "metadata.db") dest = os.path.join(library_path, "metadata.db") shutil.copyfile(src, dest) db = LibraryDatabase2(library_path) db.set_cover(1, I("lt.png", data=True)) db.set_cover(2, I("polish.png", data=True)) db.add_format(1, "FMT1", BytesIO(b"book1fmt1"), index_is_id=True) db.add_format(1, "FMT2", BytesIO(b"book1fmt2"), index_is_id=True) db.add_format(2, "FMT1", BytesIO(b"book2fmt1"), index_is_id=True) db.conn.close() return dest
def is_library_dir_suitable(self, x): try: return LibraryDatabase2.exists_at(x) or not os.listdir(x) except: return False
def is_library_dir_suitable(self, x): try: return LibraryDatabase2.exists_at(x) or not os.listdir(x) except: return False