diff --git a/session.vim b/session.vim index 54fb6305c2..f2adf71de9 100644 --- a/session.vim +++ b/session.vim @@ -1,5 +1,5 @@ " Project wide builtins -let g:pyflakes_builtins += ["dynamic_property", "__", "P", "I", "lopen"] +let g:pyflakes_builtins += ["dynamic_property", "__", "P", "I", "lopen", "icu_lower", "icu_upper", "icu_title"] python << EOFPY import os diff --git a/setup/check.py b/setup/check.py index 57c72e08c1..3e94b9dda1 100644 --- a/setup/check.py +++ b/setup/check.py @@ -63,7 +63,8 @@ class Check(Command): description = 'Check for errors in the calibre source code' - BUILTINS = ['_', '__', 'dynamic_property', 'I', 'P', 'lopen'] + BUILTINS = ['_', '__', 'dynamic_property', 'I', 'P', 'lopen', 'icu_lower', + 'icu_upper', 'icu_title'] CACHE = '.check-cache.pickle' def get_files(self, cache): diff --git a/src/calibre/ebooks/fb2/fb2ml.py b/src/calibre/ebooks/fb2/fb2ml.py index 46861357e6..51bfaa7293 100644 --- a/src/calibre/ebooks/fb2/fb2ml.py +++ b/src/calibre/ebooks/fb2/fb2ml.py @@ -20,7 +20,7 @@ from calibre import prepare_string_for_xml from calibre.constants import __appname__, __version__ from calibre.ebooks.oeb.base import XHTML, XHTML_NS, barename, namespace from calibre.ebooks.oeb.stylizer import Stylizer -from calibre.ebooks.oeb.base import OEB_RASTER_IMAGES +from calibre.ebooks.oeb.base import OEB_RASTER_IMAGES, OPF from calibre.utils.magick import Image class FB2MLizer(object): @@ -85,8 +85,8 @@ class FB2MLizer(object): metadata['version'] = __version__ metadata['date'] = '%i.%i.%i' % (datetime.now().day, datetime.now().month, datetime.now().year) metadata['lang'] = u''.join(self.oeb_book.metadata.lang) if self.oeb_book.metadata.lang else 'en' - metadata['id'] = '%s' % uuid.uuid4() - + metadata['id'] = None + author_parts = self.oeb_book.metadata.creator[0].value.split(' ') if len(author_parts) == 1: metadata['author_last'] = author_parts[0] @@ -98,6 +98,15 @@ class FB2MLizer(object): metadata['author_middle'] = ' '.join(author_parts[1:-2]) metadata['author_last'] = author_parts[-1] + identifiers = self.oeb_book.metadata['identifier'] + for x in identifiers: + if x.get(OPF('scheme'), None).lower() == 'uuid' or unicode(x).startswith('urn:uuid:'): + metadata['id'] = unicode(x).split(':')[-1] + break + if metadata['id'] is None: + self.log.warn('No UUID identifier found') + metadata['id'] = str(uuid.uuid4()) + for key, value in metadata.items(): metadata[key] = prepare_string_for_xml(value) diff --git a/src/calibre/ebooks/mobi/langcodes.py b/src/calibre/ebooks/mobi/langcodes.py index 723b619590..5d085906df 100644 --- a/src/calibre/ebooks/mobi/langcodes.py +++ b/src/calibre/ebooks/mobi/langcodes.py @@ -322,7 +322,7 @@ def iana2mobi(icode): while len(subtags) > 0: subtag = subtags.pop(0) if subtag not in langdict: - subtag = icu_title(subtag) + subtag = subtag.title() if subtag not in langdict: subtag = subtag.upper() if subtag in langdict: diff --git a/src/calibre/utils/titlecase.py b/src/calibre/utils/titlecase.py index cb0d840515..b85670f038 100755 --- a/src/calibre/utils/titlecase.py +++ b/src/calibre/utils/titlecase.py @@ -41,7 +41,6 @@ def titlecase(text): """ def capitalize(w): - print 'in capitalize' w = icu_lower(w) w = w.replace(w[0], icu_upper(w[0])) return w