mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Cleanup
This commit is contained in:
parent
6099c69d6f
commit
38b5c97eeb
@ -1393,20 +1393,20 @@ class DeviceMixin(object): # {{{
|
|||||||
del_on_upload = config['delete_news_from_library_on_upload']
|
del_on_upload = config['delete_news_from_library_on_upload']
|
||||||
settings = self.device_manager.device.settings()
|
settings = self.device_manager.device.settings()
|
||||||
ids = list(self.news_to_be_synced) if send_ids is None else send_ids
|
ids = list(self.news_to_be_synced) if send_ids is None else send_ids
|
||||||
ids = [id for id in ids if self.library_view.model().db.has_id(id)]
|
ids = [book_id for book_id in ids if self.library_view.model().db.has_id(book_id)]
|
||||||
with BusyCursor():
|
with BusyCursor():
|
||||||
files, _auto_ids = self.library_view.model().get_preferred_formats_from_ids(
|
files, _auto_ids = self.library_view.model().get_preferred_formats_from_ids(
|
||||||
ids, settings.format_map,
|
ids, settings.format_map,
|
||||||
exclude_auto=do_auto_convert)
|
exclude_auto=do_auto_convert)
|
||||||
auto = []
|
auto = []
|
||||||
if do_auto_convert and _auto_ids:
|
if do_auto_convert and _auto_ids:
|
||||||
for id in _auto_ids:
|
for book_id in _auto_ids:
|
||||||
dbfmts = self.library_view.model().db.formats(id, index_is_id=True)
|
dbfmts = self.library_view.model().db.formats(book_id, index_is_id=True)
|
||||||
formats = [] if dbfmts is None else \
|
formats = [] if dbfmts is None else \
|
||||||
[f.lower() for f in dbfmts.split(',')]
|
[f.lower() for f in dbfmts.split(',')]
|
||||||
if set(formats).intersection(available_input_formats()) \
|
if set(formats).intersection(available_input_formats()) \
|
||||||
and set(settings.format_map).intersection(available_output_formats()):
|
and set(settings.format_map).intersection(available_output_formats()):
|
||||||
auto.append(id)
|
auto.append(book_id)
|
||||||
if auto:
|
if auto:
|
||||||
format = None
|
format = None
|
||||||
for fmt in settings.format_map:
|
for fmt in settings.format_map:
|
||||||
@ -1414,7 +1414,7 @@ class DeviceMixin(object): # {{{
|
|||||||
format = fmt
|
format = fmt
|
||||||
break
|
break
|
||||||
if format is not None:
|
if format is not None:
|
||||||
autos = [self.library_view.model().db.title(id, index_is_id=True) for id in auto]
|
autos = [self.library_view.model().db.title(book_id, index_is_id=True) for book_id in auto]
|
||||||
if self.auto_convert_question(
|
if self.auto_convert_question(
|
||||||
_('Auto convert the following books before uploading to '
|
_('Auto convert the following books before uploading to '
|
||||||
'the device?'), autos):
|
'the device?'), autos):
|
||||||
@ -1425,15 +1425,15 @@ class DeviceMixin(object): # {{{
|
|||||||
return
|
return
|
||||||
metadata = self.library_view.model().metadata_for(ids)
|
metadata = self.library_view.model().metadata_for(ids)
|
||||||
names = []
|
names = []
|
||||||
for mi in metadata:
|
for book_id, mi in zip(ids, metadata):
|
||||||
prefix = ascii_filename(mi.title)
|
prefix = ascii_filename(mi.title)
|
||||||
if not isinstance(prefix, unicode_type):
|
if not isinstance(prefix, unicode_type):
|
||||||
prefix = prefix.decode(preferred_encoding, 'replace')
|
prefix = prefix.decode(preferred_encoding, 'replace')
|
||||||
prefix = ascii_filename(prefix)
|
prefix = ascii_filename(prefix)
|
||||||
names.append('%s_%d%s'%(prefix, id,
|
names.append('%s_%d%s'%(prefix, book_id,
|
||||||
os.path.splitext(files[-1])[1]))
|
os.path.splitext(files[-1])[1]))
|
||||||
self.update_thumbnail(mi)
|
self.update_thumbnail(mi)
|
||||||
self.news_to_be_synced = set([])
|
self.news_to_be_synced = set()
|
||||||
if config['upload_news_to_device'] and files:
|
if config['upload_news_to_device'] and files:
|
||||||
remove = ids if del_on_upload else []
|
remove = ids if del_on_upload else []
|
||||||
space = {self.location_manager.free[0] : None,
|
space = {self.location_manager.free[0] : None,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user