1) Added uuid to OPF with id="uuid_id", matching style when converting epubs.

2) Fixed bug lp:1098325, improperly formatted ISBN field when exporting CSV.
This commit is contained in:
GRiker 2013-01-11 14:23:54 -07:00
parent 01df610d1a
commit a1b04a765c
2 changed files with 5 additions and 8 deletions

View File

@ -458,7 +458,6 @@ def serialize_user_metadata(metadata_elem, all_user_metadata, tail='\n'+(' '*8))
from calibre.utils.config import to_json
from calibre.ebooks.metadata.book.json_codec import (object_to_unicode,
encode_is_multiple)
for name, fm in all_user_metadata.items():
try:
fm = copy.copy(fm)
@ -960,14 +959,13 @@ class OPF(object): # {{{
def fset(self, val):
matches = self.uuid_id_path(self.metadata)
if not matches:
attrib = {'{%s}scheme'%self.NAMESPACES['opf']: 'uuid'}
attrib = {'{%s}scheme'%self.NAMESPACES['opf']: 'uuid', 'id':'uuid_id'}
matches = [self.create_metadata_element('identifier',
attrib=attrib)]
self.set_text(matches[0], unicode(val))
return property(fget=fget, fset=fset)
@dynamic_property
def language(self):
@ -981,7 +979,6 @@ class OPF(object): # {{{
return property(fget=fget, fset=fset)
@dynamic_property
def languages(self):
@ -1006,7 +1003,6 @@ class OPF(object): # {{{
return property(fget=fget, fset=fset)
@dynamic_property
def book_producer(self):
@ -1152,13 +1148,14 @@ class OPF(object): # {{{
for attr in ('title', 'authors', 'author_sort', 'title_sort',
'publisher', 'series', 'series_index', 'rating',
'isbn', 'tags', 'category', 'comments', 'book_producer',
'pubdate', 'user_categories', 'author_link_map'):
'pubdate', 'user_categories', 'author_link_map','uuid'):
val = getattr(mi, attr, None)
if val is not None and val != [] and val != (None, None):
setattr(self, attr, val)
langs = getattr(mi, 'languages', [])
if langs and langs != ['und']:
self.languages = langs
self.get_identifiers = mi.get_identifiers
temp = self.to_book_metadata()
temp.smart_update(mi, replace_metadata=replace_metadata)
self._user_metadata_ = temp.get_all_user_metadata(True)

View File

@ -133,8 +133,8 @@ class CSV_XML(CatalogPlugin):
elif field in ['authors', 'tags']:
item = ', '.join(item)
elif field == 'isbn':
# Could be 9, 10 or 13 digits
item = u'%s' % re.sub(r'[\D]', '', item)
# Could be 9, 10 or 13 digits, with hyphens, possibly ending in 'X'
item = u'%s' % re.sub(r'[^\dX-]', '', item)
elif field in ['pubdate', 'timestamp']:
item = isoformat(item)
elif field == 'comments':