mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
More fixes for the is_multiple change. Several of the content server changes fix bugs that existed before the change.
This commit is contained in:
parent
d961391802
commit
fc2e4a3767
@ -621,10 +621,7 @@ class Metadata(object):
|
|||||||
orig_res = res
|
orig_res = res
|
||||||
datatype = cmeta['datatype']
|
datatype = cmeta['datatype']
|
||||||
if datatype == 'text' and cmeta['is_multiple']:
|
if datatype == 'text' and cmeta['is_multiple']:
|
||||||
if cmeta['display'].get('is_names', False):
|
res = cmeta['is_multiple']['list_to_ui'].join(res)
|
||||||
res = u' & '.join(res)
|
|
||||||
else:
|
|
||||||
res = u', '.join(sorted(res, key=sort_key))
|
|
||||||
elif datatype == 'series' and series_with_index:
|
elif datatype == 'series' and series_with_index:
|
||||||
if self.get_extra(key) is not None:
|
if self.get_extra(key) is not None:
|
||||||
res = res + \
|
res = res + \
|
||||||
@ -668,7 +665,7 @@ class Metadata(object):
|
|||||||
elif datatype == 'text' and fmeta['is_multiple']:
|
elif datatype == 'text' and fmeta['is_multiple']:
|
||||||
if isinstance(res, dict):
|
if isinstance(res, dict):
|
||||||
res = [k + ':' + v for k,v in res.items()]
|
res = [k + ':' + v for k,v in res.items()]
|
||||||
res = u', '.join(sorted(res, key=sort_key))
|
res = fmeta['is_multiple']['list_to_ui'].join(sorted(res, key=sort_key))
|
||||||
elif datatype == 'series' and series_with_index:
|
elif datatype == 'series' and series_with_index:
|
||||||
res = res + ' [%s]'%self.format_series_index()
|
res = res + ' [%s]'%self.format_series_index()
|
||||||
elif datatype == 'datetime':
|
elif datatype == 'datetime':
|
||||||
|
@ -656,18 +656,9 @@ class MetadataBulkDialog(ResizableDialog, Ui_MetadataBulkDialog):
|
|||||||
if self.destination_field_fm['is_multiple']:
|
if self.destination_field_fm['is_multiple']:
|
||||||
if self.comma_separated.isChecked():
|
if self.comma_separated.isChecked():
|
||||||
splitter = self.destination_field_fm['is_multiple']['ui_to_list']
|
splitter = self.destination_field_fm['is_multiple']['ui_to_list']
|
||||||
# if dest == 'authors' or \
|
|
||||||
# (self.destination_field_fm['is_custom'] and
|
|
||||||
# self.destination_field_fm['datatype'] == 'text' and
|
|
||||||
# self.destination_field_fm['display'].get('is_names', False)):
|
|
||||||
# splitter = ' & '
|
|
||||||
# else:
|
|
||||||
# splitter = ','
|
|
||||||
res = []
|
res = []
|
||||||
for v in val:
|
for v in val:
|
||||||
for x in v.split(splitter):
|
res.extend([x.strip() for x in v.split(splitter) if x.strip()])
|
||||||
if x.strip():
|
|
||||||
res.append(x.strip())
|
|
||||||
val = res
|
val = res
|
||||||
else:
|
else:
|
||||||
val = [v.replace(',', '') for v in val]
|
val = [v.replace(',', '') for v in val]
|
||||||
|
@ -231,7 +231,8 @@ class MobileServer(object):
|
|||||||
book['size'] = human_readable(book['size'])
|
book['size'] = human_readable(book['size'])
|
||||||
|
|
||||||
aus = record[FM['authors']] if record[FM['authors']] else __builtin__._('Unknown')
|
aus = record[FM['authors']] if record[FM['authors']] else __builtin__._('Unknown')
|
||||||
authors = '|'.join([i.replace('|', ',') for i in aus.split(',')])
|
aut_is = CFM['authors']['is_multiple']
|
||||||
|
authors = aut_is['list_to_ui'].join([i.replace('|', ',') for i in aus.split(',')])
|
||||||
book['authors'] = authors
|
book['authors'] = authors
|
||||||
book['series_index'] = fmt_sidx(float(record[FM['series_index']]))
|
book['series_index'] = fmt_sidx(float(record[FM['series_index']]))
|
||||||
book['series'] = record[FM['series']]
|
book['series'] = record[FM['series']]
|
||||||
@ -254,8 +255,10 @@ class MobileServer(object):
|
|||||||
continue
|
continue
|
||||||
if datatype == 'text' and CFM[key]['is_multiple']:
|
if datatype == 'text' and CFM[key]['is_multiple']:
|
||||||
book[key] = concat(name,
|
book[key] = concat(name,
|
||||||
format_tag_string(val, ',',
|
format_tag_string(val,
|
||||||
no_tag_count=True))
|
CFM[key]['is_multiple']['ui_to_list'],
|
||||||
|
no_tag_count=True,
|
||||||
|
joinval=CFM[key]['is_multiple']['list_to_ui']))
|
||||||
else:
|
else:
|
||||||
book[key] = concat(name, val)
|
book[key] = concat(name, val)
|
||||||
|
|
||||||
|
@ -180,9 +180,12 @@ def ACQUISITION_ENTRY(item, version, db, updated, CFM, CKEYS, prefix):
|
|||||||
if val:
|
if val:
|
||||||
datatype = CFM[key]['datatype']
|
datatype = CFM[key]['datatype']
|
||||||
if datatype == 'text' and CFM[key]['is_multiple']:
|
if datatype == 'text' and CFM[key]['is_multiple']:
|
||||||
extra.append('%s: %s<br />'%(xml(name), xml(format_tag_string(val, ',',
|
extra.append('%s: %s<br />'%
|
||||||
ignore_max=True,
|
(xml(name),
|
||||||
no_tag_count=True))))
|
xml(format_tag_string(val,
|
||||||
|
CFM[key]['is_multiple']['ui_to_list'],
|
||||||
|
ignore_max=True, no_tag_count=True,
|
||||||
|
joinval=CFM[key]['is_multiple']['list_to_ui']))))
|
||||||
elif datatype == 'comments':
|
elif datatype == 'comments':
|
||||||
extra.append('%s: %s<br />'%(xml(name), comments_to_html(unicode(val))))
|
extra.append('%s: %s<br />'%(xml(name), comments_to_html(unicode(val))))
|
||||||
else:
|
else:
|
||||||
|
@ -68,7 +68,7 @@ def strftime(fmt='%Y/%m/%d %H:%M:%S', dt=None):
|
|||||||
except:
|
except:
|
||||||
return _strftime(fmt, nowf().timetuple())
|
return _strftime(fmt, nowf().timetuple())
|
||||||
|
|
||||||
def format_tag_string(tags, sep, ignore_max=False, no_tag_count=False):
|
def format_tag_string(tags, sep, ignore_max=False, no_tag_count=False, joinval=', '):
|
||||||
MAX = sys.maxint if ignore_max else tweaks['max_content_server_tags_shown']
|
MAX = sys.maxint if ignore_max else tweaks['max_content_server_tags_shown']
|
||||||
if tags:
|
if tags:
|
||||||
tlist = [t.strip() for t in tags.split(sep)]
|
tlist = [t.strip() for t in tags.split(sep)]
|
||||||
@ -78,10 +78,10 @@ def format_tag_string(tags, sep, ignore_max=False, no_tag_count=False):
|
|||||||
if len(tlist) > MAX:
|
if len(tlist) > MAX:
|
||||||
tlist = tlist[:MAX]+['...']
|
tlist = tlist[:MAX]+['...']
|
||||||
if no_tag_count:
|
if no_tag_count:
|
||||||
return ', '.join(tlist) if tlist else ''
|
return joinval.join(tlist) if tlist else ''
|
||||||
else:
|
else:
|
||||||
return u'%s:&:%s'%(tweaks['max_content_server_tags_shown'],
|
return u'%s:&:%s'%(tweaks['max_content_server_tags_shown'],
|
||||||
', '.join(tlist)) if tlist else ''
|
joinval.join(tlist)) if tlist else ''
|
||||||
|
|
||||||
def quote(s):
|
def quote(s):
|
||||||
if isinstance(s, unicode):
|
if isinstance(s, unicode):
|
||||||
|
@ -121,8 +121,12 @@ class XMLServer(object):
|
|||||||
name = CFM[key]['name']
|
name = CFM[key]['name']
|
||||||
custcols.append(k)
|
custcols.append(k)
|
||||||
if datatype == 'text' and CFM[key]['is_multiple']:
|
if datatype == 'text' and CFM[key]['is_multiple']:
|
||||||
kwargs[k] = concat('#T#'+name, format_tag_string(val,',',
|
kwargs[k] = \
|
||||||
ignore_max=True))
|
concat('#T#'+name,
|
||||||
|
format_tag_string(val,
|
||||||
|
CFM[key]['is_multiple']['ui_to_list'],
|
||||||
|
ignore_max=True,
|
||||||
|
joinval=CFM[key]['is_multiple']['list_to_ui']))
|
||||||
else:
|
else:
|
||||||
kwargs[k] = concat(name, val)
|
kwargs[k] = concat(name, val)
|
||||||
kwargs['custcols'] = ','.join(custcols)
|
kwargs['custcols'] = ','.join(custcols)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user