Nook Color/TSR: When sending books to the storage card place them in the My Files/Books subdirectory. Fixes #792842 (NookColor External Mem Card Path)

This commit is contained in:
Kovid Goyal 2011-06-09 10:10:44 -06:00
parent abebab5331
commit 3d7d916e51
3 changed files with 17 additions and 4 deletions

View File

@ -77,7 +77,6 @@ class NOOK(USBMS):
with open('%s.jpg' % os.path.join(path, filename), 'wb') as coverfile:
coverfile.write(coverdata)
def sanitize_path_components(self, components):
return [x.replace('#', '_') for x in components]
@ -110,6 +109,11 @@ class NOOK_COLOR(NOOK):
def upload_cover(self, path, filename, metadata, filepath):
pass
def get_carda_ebook_dir(self, for_upload=False):
if for_upload:
return 'My Files/Books'
return ''
class NOOK_TSR(NOOK):
gui_name = _('Nook Simple')
description = _('Communicate with the Nook TSR eBook reader.')
@ -117,9 +121,15 @@ class NOOK_TSR(NOOK):
PRODUCT_ID = [0x003]
BCD = [0x216]
EBOOK_DIR_MAIN = EBOOK_DIR_CARD_A = 'My Files/Books'
EBOOK_DIR_MAIN = 'My Files/Books'
WINDOWS_MAIN_MEM = WINDOWS_CARD_A_MEM = 'EBOOK_DISK'
def upload_cover(self, path, filename, metadata, filepath):
pass
def get_carda_ebook_dir(self, for_upload=False):
if for_upload:
return 'My Files/Books'
return ''

View File

@ -837,6 +837,9 @@ class Device(DeviceConfig, DevicePlugin):
def get_main_ebook_dir(self, for_upload=False):
return self.EBOOK_DIR_MAIN
def get_carda_ebook_dir(self, for_upload=False):
return self.EBOOK_DIR_CARD_A
def _sanity_check(self, on_card, files):
if on_card == 'carda' and not self._card_a_prefix:
raise ValueError(_('The reader has no storage card in this slot.'))
@ -847,7 +850,7 @@ class Device(DeviceConfig, DevicePlugin):
if on_card == 'carda':
path = os.path.join(self._card_a_prefix,
*(self.EBOOK_DIR_CARD_A.split('/')))
*(self.get_carda_ebook_dir().split('/')))
elif on_card == 'cardb':
path = os.path.join(self._card_b_prefix,
*(self.EBOOK_DIR_CARD_B.split('/')))

View File

@ -132,7 +132,7 @@ class USBMS(CLI, Device):
self._card_b_prefix if oncard == 'cardb' \
else self._main_prefix
ebook_dirs = self.EBOOK_DIR_CARD_A if oncard == 'carda' else \
ebook_dirs = self.get_carda_ebook_dir() if oncard == 'carda' else \
self.EBOOK_DIR_CARD_B if oncard == 'cardb' else \
self.get_main_ebook_dir()