From 4785359e6ab1993fbc7e7f134e4882b04d82c7ab Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 1 Sep 2012 15:33:33 +0530 Subject: [PATCH] ... --- src/calibre/devices/mtp/books.py | 1 + src/calibre/devices/mtp/driver.py | 6 +++--- src/calibre/devices/mtp/test.py | 6 +++--- src/calibre/devices/mtp/unix/driver.py | 2 +- src/calibre/devices/mtp/windows/driver.py | 2 +- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/calibre/devices/mtp/books.py b/src/calibre/devices/mtp/books.py index 2179c49a8a..73e483f19e 100644 --- a/src/calibre/devices/mtp/books.py +++ b/src/calibre/devices/mtp/books.py @@ -30,6 +30,7 @@ class Book(Metadata): self.lpath = self.path = self.lpath.replace(os.sep, '/') self.mtp_relpath = tuple([icu_lower(x) for x in self.lpath.split('/')]) self.datetime = utcnow().timetuple() + self.thumbail = None def matches_file(self, mtp_file): return (self.storage_id == mtp_file.storage_id and diff --git a/src/calibre/devices/mtp/driver.py b/src/calibre/devices/mtp/driver.py index 4b26e23ef8..13e8394288 100644 --- a/src/calibre/devices/mtp/driver.py +++ b/src/calibre/devices/mtp/driver.py @@ -43,7 +43,7 @@ class MTP_DEVICE(BASE): f = storage.find_path((self.DRIVEINFO,)) dinfo = {} if f is not None: - stream = self.get_file(f) + stream = self.get_mtp_file(f) try: dinfo = json.load(stream, object_hook=from_json) except: @@ -114,7 +114,7 @@ class MTP_DEVICE(BASE): if cache is not None: json_codec = JSONCodec() try: - stream = self.get_file(cache) + stream = self.get_mtp_file(cache) json_codec.decode_from_file(stream, bl, Book, sid) except: need_sync = True @@ -166,7 +166,7 @@ class MTP_DEVICE(BASE): from calibre.ebooks.metadata.meta import get_metadata from calibre.customize.ui import quick_metadata ext = mtp_file.name.rpartition('.')[-1].lower() - stream = self.get_file(mtp_file) + stream = self.get_mtp_file(mtp_file) with quick_metadata: return get_metadata(stream, stream_type=ext, force_read_metadata=True, diff --git a/src/calibre/devices/mtp/test.py b/src/calibre/devices/mtp/test.py index 0563708ea4..c273bac5e0 100644 --- a/src/calibre/devices/mtp/test.py +++ b/src/calibre/devices/mtp/test.py @@ -128,7 +128,7 @@ class TestDeviceInteraction(unittest.TestCase): raw2 = io.BytesIO() pc = ProgressCallback() - self.dev.get_file(f, raw2, callback=pc) + self.dev.get_mtp_file(f, raw2, callback=pc) self.assertEqual(raw.getvalue(), raw2.getvalue()) self.assertTrue(pc.end_called, msg='Progress callback not called with equal values (get_file)') @@ -162,7 +162,7 @@ class TestDeviceInteraction(unittest.TestCase): self.assertEqual(f.storage_id, self.storage.storage_id) raw2 = io.BytesIO() - self.dev.get_file(f, raw2) + self.dev.get_mtp_file(f, raw2) self.assertEqual(raw.getvalue(), raw2.getvalue()) def measure_memory_usage(self, repetitions, func, *args, **kwargs): @@ -226,7 +226,7 @@ class TestDeviceInteraction(unittest.TestCase): def get_file(f): raw = io.BytesIO() pc = ProgressCallback() - self.dev.get_file(f, raw, callback=pc) + self.dev.get_mtp_file(f, raw, callback=pc) raw.truncate(0) del raw del pc diff --git a/src/calibre/devices/mtp/unix/driver.py b/src/calibre/devices/mtp/unix/driver.py index b4e8b44407..338913114f 100644 --- a/src/calibre/devices/mtp/unix/driver.py +++ b/src/calibre/devices/mtp/unix/driver.py @@ -273,7 +273,7 @@ class MTP_DEVICE(MTPDeviceBase): return parent.add_child(ans) @synchronous - def get_file(self, f, stream=None, callback=None): + def get_mtp_file(self, f, stream=None, callback=None): if f.is_folder: raise ValueError('%s if a folder'%(f.full_path,)) if stream is None: diff --git a/src/calibre/devices/mtp/windows/driver.py b/src/calibre/devices/mtp/windows/driver.py index faa5296547..7c15797ef6 100644 --- a/src/calibre/devices/mtp/windows/driver.py +++ b/src/calibre/devices/mtp/windows/driver.py @@ -293,7 +293,7 @@ class MTP_DEVICE(MTPDeviceBase): return tuple(ans) @same_thread - def get_file(self, f, stream=None, callback=None): + def get_mtp_file(self, f, stream=None, callback=None): if f.is_folder: raise ValueError('%s if a folder'%(f.full_path,)) if stream is None: