This commit is contained in:
Kovid Goyal 2014-09-21 09:52:15 +05:30
parent b127afdaa6
commit 9f529a74fa
2 changed files with 7 additions and 5 deletions

View File

@ -16,6 +16,7 @@ from calibre.utils.config_base import tweaks
from calibre.utils.icu import sort_key from calibre.utils.icu import sort_key
class Book(Metadata): class Book(Metadata):
def __init__(self, prefix, lpath, size=None, other=None): def __init__(self, prefix, lpath, size=None, other=None):
from calibre.ebooks.metadata.meta import path_to_ext from calibre.ebooks.metadata.meta import path_to_ext
@ -30,7 +31,7 @@ class Book(Metadata):
else: else:
self.lpath = lpath self.lpath = lpath
self.mime = mime_type_ext(path_to_ext(lpath)) self.mime = mime_type_ext(path_to_ext(lpath))
self.size = size # will be set later if None self.size = size # will be set later if None
try: try:
self.datetime = time.gmtime(os.path.getctime(self.path)) self.datetime = time.gmtime(os.path.getctime(self.path))
except: except:
@ -193,12 +194,13 @@ class CollectionsBookList(BookList):
# values came from. # values came from.
if attr == 'device_collections': if attr == 'device_collections':
doing_dc = True doing_dc = True
val = book.device_collections # is a list val = book.device_collections # is a list
else: else:
doing_dc = False doing_dc = False
ign, val, orig_val, fm = book.format_field_extended(attr) ign, val, orig_val, fm = book.format_field_extended(attr)
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')
if isinstance(val, (list, tuple)): if isinstance(val, (list, tuple)):
@ -221,7 +223,7 @@ class CollectionsBookList(BookList):
# comparing it to the series name. # comparing it to the series name.
if category == book.series: if category == book.series:
is_series = True is_series = True
elif fm['is_custom']: # is a custom field elif fm['is_custom']: # is a custom field
if fm['datatype'] == 'text' and len(category) > 1 and \ if fm['datatype'] == 'text' and len(category) > 1 and \
category[0] == '[' and category[-1] == ']': category[0] == '[' and category[-1] == ']':
continue continue

View File

@ -204,7 +204,7 @@ class USBMS(CLI, Device):
else: else:
ebook_dir = self.normalize_path( ebook_dir = self.normalize_path(
os.path.join(prefix, *(ebook_dir.split('/'))) os.path.join(prefix, *(ebook_dir.split('/')))
if ebook_dir else prefix) if ebook_dir else prefix)
debug_print('USBMS: scan from root', self.SCAN_FROM_ROOT, ebook_dir) debug_print('USBMS: scan from root', self.SCAN_FROM_ROOT, ebook_dir)
if not os.path.exists(ebook_dir): if not os.path.exists(ebook_dir):
continue continue