mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
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:
parent
01df610d1a
commit
a1b04a765c
@ -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.utils.config import to_json
|
||||||
from calibre.ebooks.metadata.book.json_codec import (object_to_unicode,
|
from calibre.ebooks.metadata.book.json_codec import (object_to_unicode,
|
||||||
encode_is_multiple)
|
encode_is_multiple)
|
||||||
|
|
||||||
for name, fm in all_user_metadata.items():
|
for name, fm in all_user_metadata.items():
|
||||||
try:
|
try:
|
||||||
fm = copy.copy(fm)
|
fm = copy.copy(fm)
|
||||||
@ -960,14 +959,13 @@ class OPF(object): # {{{
|
|||||||
def fset(self, val):
|
def fset(self, val):
|
||||||
matches = self.uuid_id_path(self.metadata)
|
matches = self.uuid_id_path(self.metadata)
|
||||||
if not matches:
|
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',
|
matches = [self.create_metadata_element('identifier',
|
||||||
attrib=attrib)]
|
attrib=attrib)]
|
||||||
self.set_text(matches[0], unicode(val))
|
self.set_text(matches[0], unicode(val))
|
||||||
|
|
||||||
return property(fget=fget, fset=fset)
|
return property(fget=fget, fset=fset)
|
||||||
|
|
||||||
|
|
||||||
@dynamic_property
|
@dynamic_property
|
||||||
def language(self):
|
def language(self):
|
||||||
|
|
||||||
@ -981,7 +979,6 @@ class OPF(object): # {{{
|
|||||||
|
|
||||||
return property(fget=fget, fset=fset)
|
return property(fget=fget, fset=fset)
|
||||||
|
|
||||||
|
|
||||||
@dynamic_property
|
@dynamic_property
|
||||||
def languages(self):
|
def languages(self):
|
||||||
|
|
||||||
@ -1006,7 +1003,6 @@ class OPF(object): # {{{
|
|||||||
|
|
||||||
return property(fget=fget, fset=fset)
|
return property(fget=fget, fset=fset)
|
||||||
|
|
||||||
|
|
||||||
@dynamic_property
|
@dynamic_property
|
||||||
def book_producer(self):
|
def book_producer(self):
|
||||||
|
|
||||||
@ -1152,13 +1148,14 @@ class OPF(object): # {{{
|
|||||||
for attr in ('title', 'authors', 'author_sort', 'title_sort',
|
for attr in ('title', 'authors', 'author_sort', 'title_sort',
|
||||||
'publisher', 'series', 'series_index', 'rating',
|
'publisher', 'series', 'series_index', 'rating',
|
||||||
'isbn', 'tags', 'category', 'comments', 'book_producer',
|
'isbn', 'tags', 'category', 'comments', 'book_producer',
|
||||||
'pubdate', 'user_categories', 'author_link_map'):
|
'pubdate', 'user_categories', 'author_link_map','uuid'):
|
||||||
val = getattr(mi, attr, None)
|
val = getattr(mi, attr, None)
|
||||||
if val is not None and val != [] and val != (None, None):
|
if val is not None and val != [] and val != (None, None):
|
||||||
setattr(self, attr, val)
|
setattr(self, attr, val)
|
||||||
langs = getattr(mi, 'languages', [])
|
langs = getattr(mi, 'languages', [])
|
||||||
if langs and langs != ['und']:
|
if langs and langs != ['und']:
|
||||||
self.languages = langs
|
self.languages = langs
|
||||||
|
self.get_identifiers = mi.get_identifiers
|
||||||
temp = self.to_book_metadata()
|
temp = self.to_book_metadata()
|
||||||
temp.smart_update(mi, replace_metadata=replace_metadata)
|
temp.smart_update(mi, replace_metadata=replace_metadata)
|
||||||
self._user_metadata_ = temp.get_all_user_metadata(True)
|
self._user_metadata_ = temp.get_all_user_metadata(True)
|
||||||
|
@ -133,8 +133,8 @@ class CSV_XML(CatalogPlugin):
|
|||||||
elif field in ['authors', 'tags']:
|
elif field in ['authors', 'tags']:
|
||||||
item = ', '.join(item)
|
item = ', '.join(item)
|
||||||
elif field == 'isbn':
|
elif field == 'isbn':
|
||||||
# Could be 9, 10 or 13 digits
|
# Could be 9, 10 or 13 digits, with hyphens, possibly ending in 'X'
|
||||||
item = u'%s' % re.sub(r'[\D]', '', item)
|
item = u'%s' % re.sub(r'[^\dX-]', '', item)
|
||||||
elif field in ['pubdate', 'timestamp']:
|
elif field in ['pubdate', 'timestamp']:
|
||||||
item = isoformat(item)
|
item = isoformat(item)
|
||||||
elif field == 'comments':
|
elif field == 'comments':
|
||||||
|
Loading…
x
Reference in New Issue
Block a user