From 2da2657345ccfdaf2197d8572ae22a6fd82abe44 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 23 Jul 2013 08:57:10 +0530 Subject: [PATCH] pep8 --- src/calibre/ebooks/metadata/book/base.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/calibre/ebooks/metadata/book/base.py b/src/calibre/ebooks/metadata/book/base.py index 0948ef544d..67c3fb1428 100644 --- a/src/calibre/ebooks/metadata/book/base.py +++ b/src/calibre/ebooks/metadata/book/base.py @@ -80,7 +80,7 @@ class Metadata(object): self.title = title if authors: # List of strings or [] - self.author = list(authors) if authors else []# Needed for backward compatibility + self.author = list(authors) if authors else [] # Needed for backward compatibility self.authors = list(authors) if authors else [] from calibre.ebooks.metadata.book.formatter import SafeFormat self.formatter = SafeFormat() @@ -429,8 +429,7 @@ class Metadata(object): try: src = op[0] dest = op[1] - val = formatter.safe_format\ - (src, other, 'PLUGBOARD TEMPLATE ERROR', other) + val = formatter.safe_format(src, other, 'PLUGBOARD TEMPLATE ERROR', other) if dest == 'tags': self.set(dest, [f.strip() for f in val.split(',') if f.strip()]) elif dest == 'authors': @@ -476,7 +475,7 @@ class Metadata(object): if replace_metadata: # SPECIAL_FIELDS = frozenset(['lpath', 'size', 'comments', 'thumbnail']) for attr in SC_COPYABLE_FIELDS: - setattr(self, attr, getattr(other, attr, 1.0 if \ + setattr(self, attr, getattr(other, attr, 1.0 if attr == 'series_index' else None)) self.tags = other.tags self.cover_data = getattr(other, 'cover_data', @@ -507,8 +506,10 @@ class Metadata(object): if getattr(other, 'cover_data', False): other_cover = other.cover_data[-1] self_cover = self.cover_data[-1] if self.cover_data else '' - if not self_cover: self_cover = '' - if not other_cover: other_cover = '' + if not self_cover: + self_cover = '' + if not other_cover: + other_cover = '' if len(other_cover) > len(self_cover): self.cover_data = other.cover_data @@ -517,7 +518,7 @@ class Metadata(object): meta = other.get_user_metadata(x, make_copy=True) if meta is not None: self_tags = self.get(x, []) - self.set_user_metadata(x, meta) # get... did the deepcopy + self.set_user_metadata(x, meta) # get... did the deepcopy other_tags = other.get(x, []) if meta['datatype'] == 'text' and meta['is_multiple']: # Case-insensitive but case preserving merging @@ -607,7 +608,7 @@ class Metadata(object): # Handle custom series index if key.startswith('#') and key.endswith('_index'): - tkey = key[:-6] # strip the _index + tkey = key[:-6] # strip the _index cmeta = self.get_user_metadata(tkey, make_copy=False) if cmeta and cmeta['datatype'] == 'series': if self.get(tkey): @@ -698,7 +699,7 @@ class Metadata(object): if self.title_sort: fmt('Title sort', self.title_sort) if self.authors: - fmt('Author(s)', authors_to_string(self.authors) + \ + fmt('Author(s)', authors_to_string(self.authors) + ((' [' + self.author_sort + ']') if self.author_sort and self.author_sort != _('Unknown') else '')) if self.publisher: @@ -805,3 +806,4 @@ def field_from_string(field, raw, field_metadata): return val +