mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 18:24:30 -04:00
...
This commit is contained in:
commit
4084b6c7f1
@ -102,8 +102,7 @@ class USBMS(CLI, Device):
|
|||||||
if isinstance(ebook_dirs, basestring):
|
if isinstance(ebook_dirs, basestring):
|
||||||
ebook_dirs = [ebook_dirs]
|
ebook_dirs = [ebook_dirs]
|
||||||
for ebook_dir in ebook_dirs:
|
for ebook_dir in ebook_dirs:
|
||||||
if isbytestring(ebook_dir):
|
ebook_dir = self.path_to_unicode(filesystem_encoding)
|
||||||
ebook_dir = ebook_dir.decode(filesystem_encoding)
|
|
||||||
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)
|
||||||
@ -115,8 +114,8 @@ class USBMS(CLI, Device):
|
|||||||
for path, dirs, files in os.walk(ebook_dir):
|
for path, dirs, files in os.walk(ebook_dir):
|
||||||
for filename in files:
|
for filename in files:
|
||||||
if filename != self.METADATA_CACHE:
|
if filename != self.METADATA_CACHE:
|
||||||
flist.append({'filename':filename,
|
flist.append({'filename': self.path_to_unicode(filename),
|
||||||
'path':path})
|
'path':self.path_to_unicode(path)})
|
||||||
for i, f in enumerate(flist):
|
for i, f in enumerate(flist):
|
||||||
self.report_progress(i/float(len(flist)), _('Getting list of books on device...'))
|
self.report_progress(i/float(len(flist)), _('Getting list of books on device...'))
|
||||||
changed = update_booklist(f['filename'], f['path'], prefix)
|
changed = update_booklist(f['filename'], f['path'], prefix)
|
||||||
@ -126,7 +125,7 @@ class USBMS(CLI, Device):
|
|||||||
paths = os.listdir(ebook_dir)
|
paths = os.listdir(ebook_dir)
|
||||||
for i, filename in enumerate(paths):
|
for i, filename in enumerate(paths):
|
||||||
self.report_progress((i+1) / float(len(paths)), _('Getting list of books on device...'))
|
self.report_progress((i+1) / float(len(paths)), _('Getting list of books on device...'))
|
||||||
changed = update_booklist(filename, ebook_dir, prefix)
|
changed = update_booklist(self.path_to_unicode(filename), ebook_dir, prefix)
|
||||||
if changed:
|
if changed:
|
||||||
need_sync = True
|
need_sync = True
|
||||||
|
|
||||||
@ -270,6 +269,12 @@ class USBMS(CLI, Device):
|
|||||||
|
|
||||||
self.report_progress(1.0, _('Sending metadata to device...'))
|
self.report_progress(1.0, _('Sending metadata to device...'))
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def path_to_unicode(cls, path):
|
||||||
|
if isbytestring(path):
|
||||||
|
path = path.decode(filesystem_encoding)
|
||||||
|
return path
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def normalize_path(cls, path):
|
def normalize_path(cls, path):
|
||||||
'Return path with platform native path separators'
|
'Return path with platform native path separators'
|
||||||
@ -279,9 +284,7 @@ class USBMS(CLI, Device):
|
|||||||
path = path.replace('/', '\\')
|
path = path.replace('/', '\\')
|
||||||
else:
|
else:
|
||||||
path = path.replace('\\', '/')
|
path = path.replace('\\', '/')
|
||||||
if isbytestring(path):
|
return cls.path_to_unicode(path)
|
||||||
path = path.decode(filesystem_encoding)
|
|
||||||
return path
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def parse_metadata_cache(cls, bl, prefix, name):
|
def parse_metadata_cache(cls, bl, prefix, name):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user