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
|
||||
datatype = cmeta['datatype']
|
||||
if datatype == 'text' and cmeta['is_multiple']:
|
||||
if cmeta['display'].get('is_names', False):
|
||||
res = u' & '.join(res)
|
||||
else:
|
||||
res = u', '.join(sorted(res, key=sort_key))
|
||||
res = cmeta['is_multiple']['list_to_ui'].join(res)
|
||||
elif datatype == 'series' and series_with_index:
|
||||
if self.get_extra(key) is not None:
|
||||
res = res + \
|
||||
@ -668,7 +665,7 @@ class Metadata(object):
|
||||
elif datatype == 'text' and fmeta['is_multiple']:
|
||||
if isinstance(res, dict):
|
||||
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:
|
||||
res = res + ' [%s]'%self.format_series_index()
|
||||
elif datatype == 'datetime':
|
||||
|
@ -656,18 +656,9 @@ class MetadataBulkDialog(ResizableDialog, Ui_MetadataBulkDialog):
|
||||
if self.destination_field_fm['is_multiple']:
|
||||
if self.comma_separated.isChecked():
|
||||
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 = []
|
||||
for v in val:
|
||||
for x in v.split(splitter):
|
||||
if x.strip():
|
||||
res.append(x.strip())
|
||||
res.extend([x.strip() for x in v.split(splitter) if x.strip()])
|
||||
val = res
|
||||
else:
|
||||
val = [v.replace(',', '') for v in val]
|
||||
|
@ -231,7 +231,8 @@ class MobileServer(object):
|
||||
book['size'] = human_readable(book['size'])
|
||||
|
||||
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['series_index'] = fmt_sidx(float(record[FM['series_index']]))
|
||||
book['series'] = record[FM['series']]
|
||||
@ -254,8 +255,10 @@ class MobileServer(object):
|
||||
continue
|
||||
if datatype == 'text' and CFM[key]['is_multiple']:
|
||||
book[key] = concat(name,
|
||||
format_tag_string(val, ',',
|
||||
no_tag_count=True))
|
||||
format_tag_string(val,
|
||||
CFM[key]['is_multiple']['ui_to_list'],
|
||||
no_tag_count=True,
|
||||
joinval=CFM[key]['is_multiple']['list_to_ui']))
|
||||
else:
|
||||
book[key] = concat(name, val)
|
||||
|
||||
|
@ -180,9 +180,12 @@ def ACQUISITION_ENTRY(item, version, db, updated, CFM, CKEYS, prefix):
|
||||
if val:
|
||||
datatype = CFM[key]['datatype']
|
||||
if datatype == 'text' and CFM[key]['is_multiple']:
|
||||
extra.append('%s: %s<br />'%(xml(name), xml(format_tag_string(val, ',',
|
||||
ignore_max=True,
|
||||
no_tag_count=True))))
|
||||
extra.append('%s: %s<br />'%
|
||||
(xml(name),
|
||||
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':
|
||||
extra.append('%s: %s<br />'%(xml(name), comments_to_html(unicode(val))))
|
||||
else:
|
||||
|
@ -68,7 +68,7 @@ def strftime(fmt='%Y/%m/%d %H:%M:%S', dt=None):
|
||||
except:
|
||||
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']
|
||||
if tags:
|
||||
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:
|
||||
tlist = tlist[:MAX]+['...']
|
||||
if no_tag_count:
|
||||
return ', '.join(tlist) if tlist else ''
|
||||
return joinval.join(tlist) if tlist else ''
|
||||
else:
|
||||
return u'%s:&:%s'%(tweaks['max_content_server_tags_shown'],
|
||||
', '.join(tlist)) if tlist else ''
|
||||
joinval.join(tlist)) if tlist else ''
|
||||
|
||||
def quote(s):
|
||||
if isinstance(s, unicode):
|
||||
|
@ -121,8 +121,12 @@ class XMLServer(object):
|
||||
name = CFM[key]['name']
|
||||
custcols.append(k)
|
||||
if datatype == 'text' and CFM[key]['is_multiple']:
|
||||
kwargs[k] = concat('#T#'+name, format_tag_string(val,',',
|
||||
ignore_max=True))
|
||||
kwargs[k] = \
|
||||
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:
|
||||
kwargs[k] = concat(name, val)
|
||||
kwargs['custcols'] = ','.join(custcols)
|
||||
|
Loading…
x
Reference in New Issue
Block a user