mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 10:44:09 -04:00
Add is_multiple2 to the OPF
This commit is contained in:
parent
1f630c84b5
commit
4e34b03c2e
@ -460,6 +460,7 @@ def serialize_user_metadata(metadata_elem, all_user_metadata, tail='\n'+(' '*8))
|
|||||||
if fm.get('is_multiple'):
|
if fm.get('is_multiple'):
|
||||||
# migrate is_multiple back to a character
|
# migrate is_multiple back to a character
|
||||||
fm = copy.copy(fm)
|
fm = copy.copy(fm)
|
||||||
|
fm['is_multiple2'] = fm.get('is_multiple', {})
|
||||||
dt = fm.get('datatype', None)
|
dt = fm.get('datatype', None)
|
||||||
if dt == 'composite':
|
if dt == 'composite':
|
||||||
fm['is_multiple'] = ','
|
fm['is_multiple'] = ','
|
||||||
@ -593,17 +594,25 @@ class OPF(object): # {{{
|
|||||||
fm = elem.get('content')
|
fm = elem.get('content')
|
||||||
try:
|
try:
|
||||||
fm = json.loads(fm, object_hook=from_json)
|
fm = json.loads(fm, object_hook=from_json)
|
||||||
im = fm.get('is_multiple', None)
|
im = fm.get('is_multiple2', None)
|
||||||
if im and not isinstance(im, dict):
|
if im:
|
||||||
# Must migrate the is_multiple from char to dict
|
|
||||||
dt = fm.get('datatype', None)
|
|
||||||
if dt == 'composite':
|
|
||||||
im = {'cache_to_list': ',', 'ui_to_list': ',', 'list_to_ui': ', '}
|
|
||||||
elif fm.get('display', {}).get('is_names', False):
|
|
||||||
im = {'cache_to_list': '|', 'ui_to_list': '&', 'list_to_ui': ', '}
|
|
||||||
else:
|
|
||||||
im = {'cache_to_list': '|', 'ui_to_list': ',', 'list_to_ui': ', '}
|
|
||||||
fm['is_multiple'] = im
|
fm['is_multiple'] = im
|
||||||
|
del fm['is_multiple2']
|
||||||
|
else:
|
||||||
|
# Must migrate the is_multiple from char to dict
|
||||||
|
im = fm.get('is_multiple', None)
|
||||||
|
if im:
|
||||||
|
dt = fm.get('datatype', None)
|
||||||
|
if dt == 'composite':
|
||||||
|
im = {'cache_to_list': ',', 'ui_to_list': ',',
|
||||||
|
'list_to_ui': ', '}
|
||||||
|
elif fm.get('display', {}).get('is_names', False):
|
||||||
|
im = {'cache_to_list': '|', 'ui_to_list': '&',
|
||||||
|
'list_to_ui': ', '}
|
||||||
|
else:
|
||||||
|
im = {'cache_to_list': '|', 'ui_to_list': ',',
|
||||||
|
'list_to_ui': ', '}
|
||||||
|
fm['is_multiple'] = im
|
||||||
temp.set_user_metadata(name, fm)
|
temp.set_user_metadata(name, fm)
|
||||||
except:
|
except:
|
||||||
prints('Failed to read user metadata:', name)
|
prints('Failed to read user metadata:', name)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user