mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
b13
This commit is contained in:
parent
8d2a578832
commit
fdf4c4342f
@ -2,7 +2,7 @@ __license__ = 'GPL v3'
|
|||||||
__copyright__ = '2008, Kovid Goyal kovid@kovidgoyal.net'
|
__copyright__ = '2008, Kovid Goyal kovid@kovidgoyal.net'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
__appname__ = 'calibre'
|
__appname__ = 'calibre'
|
||||||
__version__ = '0.4.84b12'
|
__version__ = '0.4.84b13'
|
||||||
__author__ = "Kovid Goyal <kovid@kovidgoyal.net>"
|
__author__ = "Kovid Goyal <kovid@kovidgoyal.net>"
|
||||||
'''
|
'''
|
||||||
Various run time constants.
|
Various run time constants.
|
||||||
|
@ -514,12 +514,15 @@ class LibraryDatabase2(LibraryDatabase):
|
|||||||
p.save(path)
|
p.save(path)
|
||||||
|
|
||||||
def formats(self, index, index_is_id=False):
|
def formats(self, index, index_is_id=False):
|
||||||
''' Return available formats as a comma separated list '''
|
''' Return available formats as a comma separated list or None if htere are no available formats '''
|
||||||
id = index if index_is_id else self.id(index)
|
id = index if index_is_id else self.id(index)
|
||||||
path = os.path.join(self.library_path, self.path(id, index_is_id=True))
|
path = os.path.join(self.library_path, self.path(id, index_is_id=True))
|
||||||
formats = self.conn.execute('SELECT format FROM data WHERE book=?', (id,)).fetchall()
|
try:
|
||||||
name = self.conn.execute('SELECT name FROM data WHERE book=?', (id,)).fetchone()[0]
|
formats = self.conn.execute('SELECT format FROM data WHERE book=?', (id,)).fetchall()
|
||||||
formats = map(lambda x:x[0], formats)
|
name = self.conn.execute('SELECT name FROM data WHERE book=?', (id,)).fetchone()[0]
|
||||||
|
formats = map(lambda x:x[0], formats)
|
||||||
|
except:
|
||||||
|
return None
|
||||||
ans = []
|
ans = []
|
||||||
for format in formats:
|
for format in formats:
|
||||||
_format = ('.' + format.lower()) if format else ''
|
_format = ('.' + format.lower()) if format else ''
|
||||||
@ -573,7 +576,7 @@ class LibraryDatabase2(LibraryDatabase):
|
|||||||
if os.path.exists(path):
|
if os.path.exists(path):
|
||||||
shutil.rmtree(path)
|
shutil.rmtree(path)
|
||||||
parent = os.path.dirname(path)
|
parent = os.path.dirname(path)
|
||||||
if not os.listdir(parent):
|
if len(os.listdir(parent)) == 0:
|
||||||
shutil.rmtree(parent)
|
shutil.rmtree(parent)
|
||||||
self.conn.execute('DELETE FROM books WHERE id=?', (id,))
|
self.conn.execute('DELETE FROM books WHERE id=?', (id,))
|
||||||
self.conn.commit()
|
self.conn.commit()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user