Esempio n. 1
0
 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
Esempio n. 2
0
 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
Esempio n. 3
0
 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)
Esempio n. 4
0
 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)
Esempio n. 5
0
 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
Esempio n. 6
0
 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
Esempio n. 7
0
File: base.py Progetto: Qyy/calibre
    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
Esempio n. 8
0
 def is_library_dir_suitable(self, x):
     try:
         return LibraryDatabase2.exists_at(x) or not os.listdir(x)
     except:
         return False
Esempio n. 9
0
 def is_library_dir_suitable(self, x):
     try:
         return LibraryDatabase2.exists_at(x) or not os.listdir(x)
     except:
         return False