mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 10:44:09 -04:00
...
This commit is contained in:
parent
7b2a947a86
commit
4785359e6a
@ -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
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user