Merge from trunk

This commit is contained in:
Charles Haley 2010-12-05 17:14:00 +00:00
commit b2f67e4a78
5 changed files with 16 additions and 7 deletions

View File

@ -1,5 +1,5 @@
" Project wide builtins " 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 python << EOFPY
import os import os

View File

@ -63,7 +63,8 @@ class Check(Command):
description = 'Check for errors in the calibre source code' 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' CACHE = '.check-cache.pickle'
def get_files(self, cache): def get_files(self, cache):

View File

@ -20,7 +20,7 @@ from calibre import prepare_string_for_xml
from calibre.constants import __appname__, __version__ from calibre.constants import __appname__, __version__
from calibre.ebooks.oeb.base import XHTML, XHTML_NS, barename, namespace from calibre.ebooks.oeb.base import XHTML, XHTML_NS, barename, namespace
from calibre.ebooks.oeb.stylizer import Stylizer 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 from calibre.utils.magick import Image
class FB2MLizer(object): class FB2MLizer(object):
@ -85,8 +85,8 @@ class FB2MLizer(object):
metadata['version'] = __version__ metadata['version'] = __version__
metadata['date'] = '%i.%i.%i' % (datetime.now().day, datetime.now().month, datetime.now().year) 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['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(' ') author_parts = self.oeb_book.metadata.creator[0].value.split(' ')
if len(author_parts) == 1: if len(author_parts) == 1:
metadata['author_last'] = author_parts[0] metadata['author_last'] = author_parts[0]
@ -98,6 +98,15 @@ class FB2MLizer(object):
metadata['author_middle'] = ' '.join(author_parts[1:-2]) metadata['author_middle'] = ' '.join(author_parts[1:-2])
metadata['author_last'] = author_parts[-1] 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(): for key, value in metadata.items():
metadata[key] = prepare_string_for_xml(value) metadata[key] = prepare_string_for_xml(value)

View File

@ -322,7 +322,7 @@ def iana2mobi(icode):
while len(subtags) > 0: while len(subtags) > 0:
subtag = subtags.pop(0) subtag = subtags.pop(0)
if subtag not in langdict: if subtag not in langdict:
subtag = icu_title(subtag) subtag = subtag.title()
if subtag not in langdict: if subtag not in langdict:
subtag = subtag.upper() subtag = subtag.upper()
if subtag in langdict: if subtag in langdict:

View File

@ -41,7 +41,6 @@ def titlecase(text):
""" """
def capitalize(w): def capitalize(w):
print 'in capitalize'
w = icu_lower(w) w = icu_lower(w)
w = w.replace(w[0], icu_upper(w[0])) w = w.replace(w[0], icu_upper(w[0]))
return w return w