mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Ensure that strings are stripped before they are used
This commit is contained in:
parent
4ed3c28463
commit
34ff4216d5
@ -59,8 +59,8 @@ class EditAuthorsDialog(QDialog, Ui_EditAuthorsDialog):
|
|||||||
self.result = []
|
self.result = []
|
||||||
for row in range(0,self.table.rowCount()):
|
for row in range(0,self.table.rowCount()):
|
||||||
id = self.table.item(row, 0).data(Qt.UserRole).toInt()[0]
|
id = self.table.item(row, 0).data(Qt.UserRole).toInt()[0]
|
||||||
aut = unicode(self.table.item(row, 0).text())
|
aut = unicode(self.table.item(row, 0).text()).strip()
|
||||||
sort = unicode(self.table.item(row, 1).text())
|
sort = unicode(self.table.item(row, 1).text()).strip()
|
||||||
orig_aut,orig_sort = self.authors[id]
|
orig_aut,orig_sort = self.authors[id]
|
||||||
if orig_aut != aut or orig_sort != sort:
|
if orig_aut != aut or orig_sort != sort:
|
||||||
self.result.append((id, orig_aut, aut, sort))
|
self.result.append((id, orig_aut, aut, sort))
|
||||||
@ -68,7 +68,7 @@ class EditAuthorsDialog(QDialog, Ui_EditAuthorsDialog):
|
|||||||
def cell_changed(self, row, col):
|
def cell_changed(self, row, col):
|
||||||
if col == 0:
|
if col == 0:
|
||||||
item = self.table.item(row, 0)
|
item = self.table.item(row, 0)
|
||||||
aut = unicode(item.text())
|
aut = unicode(item.text()).strip()
|
||||||
c = self.table.item(row, 1)
|
c = self.table.item(row, 1)
|
||||||
c.setText(author_to_author_sort(aut))
|
c.setText(author_to_author_sort(aut))
|
||||||
item = c
|
item = c
|
||||||
|
@ -1045,6 +1045,7 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns):
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
def rename_tag(self, old_id, new_name):
|
def rename_tag(self, old_id, new_name):
|
||||||
|
new_name = new_name.strip()
|
||||||
new_id = self.conn.get(
|
new_id = self.conn.get(
|
||||||
'''SELECT id from tags
|
'''SELECT id from tags
|
||||||
WHERE name=?''', (new_name,), all=False)
|
WHERE name=?''', (new_name,), all=False)
|
||||||
@ -1084,6 +1085,7 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns):
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
def rename_series(self, old_id, new_name):
|
def rename_series(self, old_id, new_name):
|
||||||
|
new_name = new_name.strip()
|
||||||
new_id = self.conn.get(
|
new_id = self.conn.get(
|
||||||
'''SELECT id from series
|
'''SELECT id from series
|
||||||
WHERE name=?''', (new_name,), all=False)
|
WHERE name=?''', (new_name,), all=False)
|
||||||
@ -1128,6 +1130,7 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns):
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
def rename_publisher(self, old_id, new_name):
|
def rename_publisher(self, old_id, new_name):
|
||||||
|
new_name = new_name.strip()
|
||||||
new_id = self.conn.get(
|
new_id = self.conn.get(
|
||||||
'''SELECT id from publishers
|
'''SELECT id from publishers
|
||||||
WHERE name=?''', (new_name,), all=False)
|
WHERE name=?''', (new_name,), all=False)
|
||||||
@ -1158,7 +1161,7 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns):
|
|||||||
|
|
||||||
def set_sort_field_for_author(self, old_id, new_sort):
|
def set_sort_field_for_author(self, old_id, new_sort):
|
||||||
self.conn.execute('UPDATE authors SET sort=? WHERE id=?', \
|
self.conn.execute('UPDATE authors SET sort=? WHERE id=?', \
|
||||||
(new_sort, old_id))
|
(new_sort.strip(), old_id))
|
||||||
self.conn.commit()
|
self.conn.commit()
|
||||||
# Now change all the author_sort fields in books by this author
|
# Now change all the author_sort fields in books by this author
|
||||||
bks = self.conn.get('SELECT book from books_authors_link WHERE author=?', (old_id,))
|
bks = self.conn.get('SELECT book from books_authors_link WHERE author=?', (old_id,))
|
||||||
@ -1168,7 +1171,7 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns):
|
|||||||
|
|
||||||
def rename_author(self, old_id, new_name):
|
def rename_author(self, old_id, new_name):
|
||||||
# Make sure that any commas in new_name are changed to '|'!
|
# Make sure that any commas in new_name are changed to '|'!
|
||||||
new_name = new_name.replace(',', '|')
|
new_name = new_name.replace(',', '|').strip()
|
||||||
|
|
||||||
# Get the list of books we must fix up, one way or the other
|
# Get the list of books we must fix up, one way or the other
|
||||||
# Save the list so we can use it twice
|
# Save the list so we can use it twice
|
||||||
|
Loading…
x
Reference in New Issue
Block a user