mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Merge branch 'master' of https://github.com/cbhaley/calibre into master
This commit is contained in:
commit
02dcac0702
@ -436,6 +436,19 @@ class Metadata(object):
|
|||||||
_data = object.__getattribute__(self, '_data')
|
_data = object.__getattribute__(self, '_data')
|
||||||
_data['user_metadata'][field] = m
|
_data['user_metadata'][field] = m
|
||||||
|
|
||||||
|
def remove_stale_user_metadata(self, other_mi):
|
||||||
|
'''
|
||||||
|
Remove user metadata keys (custom column keys) if they
|
||||||
|
don't exist in 'other_mi', which must be a metadata object
|
||||||
|
'''
|
||||||
|
me = self.get_all_user_metadata(make_copy=False)
|
||||||
|
other = set(other_mi.custom_field_keys())
|
||||||
|
new = {}
|
||||||
|
for k,v in me.items():
|
||||||
|
if k in other:
|
||||||
|
new[k] = v
|
||||||
|
self.set_all_user_metadata(new)
|
||||||
|
|
||||||
def template_to_attribute(self, other, ops):
|
def template_to_attribute(self, other, ops):
|
||||||
'''
|
'''
|
||||||
Takes a list [(src,dest), (src,dest)], evaluates the template in the
|
Takes a list [(src,dest), (src,dest)], evaluates the template in the
|
||||||
|
@ -1312,6 +1312,7 @@ class OPF(object): # {{{
|
|||||||
if apply_null or langs:
|
if apply_null or langs:
|
||||||
self.languages = langs or []
|
self.languages = langs or []
|
||||||
temp = self.to_book_metadata()
|
temp = self.to_book_metadata()
|
||||||
|
temp.remove_stale_user_metadata(mi)
|
||||||
temp.smart_update(mi, replace_metadata=replace_metadata)
|
temp.smart_update(mi, replace_metadata=replace_metadata)
|
||||||
if not replace_metadata and callable(getattr(temp, 'custom_field_keys', None)):
|
if not replace_metadata and callable(getattr(temp, 'custom_field_keys', None)):
|
||||||
# We have to replace non-null fields regardless of the value of
|
# We have to replace non-null fields regardless of the value of
|
||||||
|
@ -1066,6 +1066,7 @@ def apply_metadata(root, mi, cover_prefix='', cover_data=None, apply_null=False,
|
|||||||
set_application_id(root, prefixes, refines, mi.application_id)
|
set_application_id(root, prefixes, refines, mi.application_id)
|
||||||
if mi.uuid:
|
if mi.uuid:
|
||||||
set_uuid(root, prefixes, refines, mi.uuid)
|
set_uuid(root, prefixes, refines, mi.uuid)
|
||||||
|
current_mi.remove_stale_user_metadata(mi)
|
||||||
new_user_metadata, current_user_metadata = mi.get_all_user_metadata(True), current_mi.get_all_user_metadata(True)
|
new_user_metadata, current_user_metadata = mi.get_all_user_metadata(True), current_mi.get_all_user_metadata(True)
|
||||||
missing = object()
|
missing = object()
|
||||||
for key in tuple(new_user_metadata):
|
for key in tuple(new_user_metadata):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user