Change bulk edit and the template function titlecase to use utils.titlecase instead of str.title()

This commit is contained in:
Charles Haley 2010-10-22 12:31:56 +01:00
parent bf3030d173
commit 8ad31bbf08
2 changed files with 6 additions and 4 deletions

View File

@ -16,6 +16,7 @@ from calibre.gui2.custom_column_widgets import populate_metadata_page
from calibre.gui2 import error_dialog
from calibre.gui2.progress_indicator import ProgressIndicator
from calibre.utils.config import dynamic
from calibre.utils.titlecase import titlecase
class MyBlockingBusy(QDialog):
@ -115,7 +116,7 @@ class MyBlockingBusy(QDialog):
aum = [a.strip().replace('|', ',') for a in aum.split(',')]
new_title = authors_to_string(aum)
if do_title_case:
new_title = new_title.title()
new_title = titlecase(new_title)
self.db.set_title(id, new_title, notify=False)
title_set = True
if title:
@ -123,7 +124,7 @@ class MyBlockingBusy(QDialog):
self.db.set_authors(id, new_authors, notify=False)
if do_title_case and not title_set:
title = self.db.title(id, index_is_id=True)
self.db.set_title(id, title.title(), notify=False)
self.db.set_title(id, titlecase(title), notify=False)
if au:
self.db.set_authors(id, string_to_authors(au), notify=False)
elif self.current_phase == 2:
@ -179,7 +180,7 @@ class MetadataBulkDialog(QDialog, Ui_MetadataBulkDialog):
s_r_functions = { '' : lambda x: x,
_('Lower Case') : lambda x: x.lower(),
_('Upper Case') : lambda x: x.upper(),
_('Title Case') : lambda x: x.title(),
_('Title Case') : lambda x: titlecase(x),
}
s_r_match_modes = [ _('Character match'),

View File

@ -7,6 +7,7 @@ Created on 23 Sep 2010
import re, string, traceback
from calibre.constants import DEBUG
from calibre.utils.titlecase import titlecase
class TemplateFormatter(string.Formatter):
'''
@ -81,7 +82,7 @@ class TemplateFormatter(string.Formatter):
functions = {
'uppercase' : (0, lambda s,x: x.upper()),
'lowercase' : (0, lambda s,x: x.lower()),
'titlecase' : (0, lambda s,x: x.title()),
'titlecase' : (0, lambda s,x: titlecase(x)),
'capitalize' : (0, lambda s,x: x.capitalize()),
'contains' : (3, _contains),
'ifempty' : (1, _ifempty),