mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
...
This commit is contained in:
commit
aecf89a5b5
@ -141,7 +141,9 @@ class CollectionsBookList(BookList):
|
|||||||
cust_field_meta = book.get_all_user_metadata(make_copy=False)
|
cust_field_meta = book.get_all_user_metadata(make_copy=False)
|
||||||
for attr in attrs:
|
for attr in attrs:
|
||||||
attr = attr.strip()
|
attr = attr.strip()
|
||||||
ign, val = book.format_field(attr, ignore_series_index=True)
|
ign, val = book.format_field(attr,
|
||||||
|
ignore_series_index=True,
|
||||||
|
return_multiples_as_list=True)
|
||||||
if not val: continue
|
if not val: continue
|
||||||
if isbytestring(val):
|
if isbytestring(val):
|
||||||
val = val.decode(preferred_encoding, 'replace')
|
val = val.decode(preferred_encoding, 'replace')
|
||||||
|
@ -343,7 +343,8 @@ class Metadata(object):
|
|||||||
def format_rating(self):
|
def format_rating(self):
|
||||||
return unicode(self.rating)
|
return unicode(self.rating)
|
||||||
|
|
||||||
def format_field(self, key, ignore_series_index=False):
|
def format_field(self, key, ignore_series_index=False,
|
||||||
|
return_multiples_as_list=False):
|
||||||
from calibre.ebooks.metadata import authors_to_string
|
from calibre.ebooks.metadata import authors_to_string
|
||||||
'''
|
'''
|
||||||
returns the tuple (field_name, formatted_value)
|
returns the tuple (field_name, formatted_value)
|
||||||
@ -356,7 +357,8 @@ class Metadata(object):
|
|||||||
name = unicode(cmeta['name'])
|
name = unicode(cmeta['name'])
|
||||||
datatype = cmeta['datatype']
|
datatype = cmeta['datatype']
|
||||||
if datatype == 'text' and cmeta['is_multiple']:
|
if datatype == 'text' and cmeta['is_multiple']:
|
||||||
res = u', '.join(res)
|
if not return_multiples_as_list:
|
||||||
|
res = u', '.join(res)
|
||||||
elif datatype == 'series':
|
elif datatype == 'series':
|
||||||
if not ignore_series_index:
|
if not ignore_series_index:
|
||||||
res = res + \
|
res = res + \
|
||||||
@ -365,7 +367,7 @@ class Metadata(object):
|
|||||||
res = format_date(res, cmeta['display'].get('date_format','dd MMM yyyy'))
|
res = format_date(res, cmeta['display'].get('date_format','dd MMM yyyy'))
|
||||||
elif datatype == 'bool':
|
elif datatype == 'bool':
|
||||||
res = _('Yes') if res else _('No')
|
res = _('Yes') if res else _('No')
|
||||||
return (name, unicode(res))
|
return (name, res)
|
||||||
|
|
||||||
if key in field_metadata and field_metadata[key]['kind'] == 'field':
|
if key in field_metadata and field_metadata[key]['kind'] == 'field':
|
||||||
res = self.get(key, None)
|
res = self.get(key, None)
|
||||||
@ -377,13 +379,14 @@ class Metadata(object):
|
|||||||
if key == 'authors':
|
if key == 'authors':
|
||||||
res = authors_to_string(res)
|
res = authors_to_string(res)
|
||||||
elif datatype == 'text' and fmeta['is_multiple']:
|
elif datatype == 'text' and fmeta['is_multiple']:
|
||||||
res = u', '.join(res)
|
if not return_multiples_as_list:
|
||||||
|
res = u', '.join(res)
|
||||||
elif datatype == 'series':
|
elif datatype == 'series':
|
||||||
if not ignore_series_index:
|
if not ignore_series_index:
|
||||||
res = res + ' [%s]'%self.format_series_index()
|
res = res + ' [%s]'%self.format_series_index()
|
||||||
elif datatype == 'datetime':
|
elif datatype == 'datetime':
|
||||||
res = format_date(res, fmeta['display'].get('date_format','dd MMM yyyy'))
|
res = format_date(res, fmeta['display'].get('date_format','dd MMM yyyy'))
|
||||||
return (name, unicode(res))
|
return (name, res)
|
||||||
|
|
||||||
return (None, None)
|
return (None, None)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user