version 0.4.7. Fix nasty bug in metadata handling.

This commit is contained in:
Kovid Goyal 2007-09-30 19:38:05 +00:00
parent 43300a23f2
commit 96415015a6
4 changed files with 12 additions and 9 deletions

View File

@ -13,7 +13,7 @@
## with this program; if not, write to the Free Software Foundation, Inc.,
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
''' E-book management software'''
__version__ = "0.4.6"
__version__ = "0.4.7"
__docformat__ = "epytext"
__author__ = "Kovid Goyal <kovid@kovidgoyal.net>"
__appname__ = 'libprs500'

View File

@ -62,7 +62,7 @@ class MetaInformation(object):
def __str__(self):
ans = ''
ans += 'Title : ' + str(self.title) + '\n'
ans += 'Author : ' + ', '.join(self.authors) + '\n'
ans += 'Author : ' + (', '.join(self.authors) if self.authors is not None else 'None') + '\n'
ans += 'Category: ' + str(self.category) + '\n'
ans += 'Comments: ' + str(self.comments) + '\n'
return ans.strip()

View File

@ -281,7 +281,7 @@ class Main(MainWindow, Ui_MainWindow):
metadata.append(mi)
names.append(os.path.basename(book))
if not mi.authors:
mi.authors = 'Unknown'
mi.authors = ['Unknown']
infos.append({'title':mi.title, 'authors':', '.join(mi.authors),
'cover':self.default_thumbnail, 'tags':[]})

View File

@ -891,15 +891,18 @@ class LibraryDatabase(object):
'''
if not append:
self.conn.execute('DELETE FROM books_tags_link WHERE book=?', (id,))
tag = set(tags)
for tag in tags:
t = self.conn.execute('SELECT id from tags WHERE name=?', (tag,)).fetchone()
for tag in set(tags):
tag = tag.strip()
if not tag:
continue
t = self.conn.execute('SELECT id FROM tags WHERE name=?', (tag,)).fetchone()
if t:
tid = t[0]
else:
tid = self.conn.execute('INSERT INTO tags(name) VALUES(?)', (tag,)).lastrowid
if (append and not self.conn.execute('SELECT book FROM books_tags_link WHERE book=? AND tag=?',
(id, tid)).fetchone()) or not append:
if not self.conn.execute('SELECT book FROM books_tags_link WHERE book=? AND tag=?',
(id, tid)).fetchone():
self.conn.execute('INSERT INTO books_tags_link(book, tag) VALUES (?,?)',
(id, tid))
self.conn.commit()