Tag Mapper: Allow Title-casing of tags. Fixes #1823097 [Feature Request: Tag Mapper Option - Title Case](https://bugs.launchpad.net/calibre/+bug/1823097)

This commit is contained in:
Kovid Goyal 2019-04-12 09:09:02 +05:30
parent 6dd0f72bae
commit 7308f4073f
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 7 additions and 0 deletions

View File

@ -82,6 +82,10 @@ def apply_rules(tag, rules):
if ac == 'capitalize':
ans.append(tag.capitalize())
break
if ac == 'titlecase':
from calibre.utils.titlecase import titlecase
ans.append(titlecase(tag))
break
if ac == 'lower':
ans.append(icu_lower(tag))
break
@ -149,6 +153,7 @@ def find_tests():
self.assertEqual(ans, expected)
run(rule('capitalize', 't1,t2'), 't1,x1', 'T1,x1')
run(rule('titlecase', 'some tag'), 'some tag,x1', 'Some Tag,x1')
run(rule('upper', 'ta,t2'), 'ta,x1', 'TA,x1')
run(rule('lower', 'ta,x1'), 'TA,X1', 'ta,x1')
run(rule('replace', 't1', 't2'), 't1,x1', 't2,x1')

View File

@ -47,6 +47,7 @@ class RuleEdit(QWidget):
('replace', _('Replace')),
('keep', _('Keep')),
('capitalize', _('Capitalize')),
('titlecase', _('Title-case')),
('lower', _('Lower-case')),
('upper', _('Upper-case')),
('split', _('Split')),

View File

@ -1,5 +1,6 @@
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals
"""
Original Perl version by: John Gruber https://daringfireball.net/ 10 May 2008