From 4cc5e18606af68984d61894f43d6af82e789ca3e Mon Sep 17 00:00:00 2001 From: John Schember Date: Sat, 31 Oct 2009 11:33:30 -0400 Subject: [PATCH] Remove stray setup. Revert create_upload_path to work with the custom path when sending to device. --- setup/installer/osx/freeze.py | 1 - src/calibre/devices/usbms/device.py | 53 ++++------------------------- 2 files changed, 7 insertions(+), 47 deletions(-) diff --git a/setup/installer/osx/freeze.py b/setup/installer/osx/freeze.py index f30a037703..bc764d25d2 100644 --- a/setup/installer/osx/freeze.py +++ b/setup/installer/osx/freeze.py @@ -10,7 +10,6 @@ from setup import __version__ as VERSION, __appname__ as APPNAME, SRC, Command, try: from setuptools import setup except: - setup class setup: pass diff --git a/src/calibre/devices/usbms/device.py b/src/calibre/devices/usbms/device.py index 0799f6779b..86f8de8e39 100644 --- a/src/calibre/devices/usbms/device.py +++ b/src/calibre/devices/usbms/device.py @@ -702,52 +702,13 @@ class Device(DeviceConfig, DevicePlugin): raise FreeSpaceError(_("There is insufficient free space on the storage card")) return path - def create_upload_path(self, path, mdata, fname): - path = os.path.abspath(path) - newpath = path - extra_components = [] - - if self.SUPPORTS_SUB_DIRS and self.settings().use_subdirs: - if 'tags' in mdata.keys(): - for tag in mdata['tags']: - if tag.startswith(_('News')): - extra_components.append('news') - c = sanitize(mdata.get('title', '')) - if c: - extra_components.append(c) - c = sanitize(mdata.get('timestamp', '')) - if c: - extra_components.append(c) - break - elif tag.startswith('/'): - for c in tag.split('/'): - c = sanitize(c) - if not c: continue - extra_components.append(c) - break - - if not extra_components: - c = sanitize(mdata.get('authors', _('Unknown'))) - if c: - extra_components.append(c) - c = sanitize(mdata.get('title', _('Unknown'))) - if c: - extra_components.append(c) - newpath = os.path.join(newpath, c) - - fname = sanitize(fname) - extra_components.append(fname) - extra_components = [str(x) for x in extra_components] - def remove_trailing_periods(x): - ans = x - while ans.endswith('.'): - ans = ans[:-1] - if not ans: - ans = 'x' - return ans - extra_components = list(map(remove_trailing_periods, extra_components)) - components = shorten_components_to(250 - len(path), extra_components) - filepath = os.path.join(path, *components) + def create_upload_path(self, root, mdata, ext, id): + from calibre.library.save_to_disk import config, get_components + opts = config().parse() + components = get_components(opts.template, mdata, id, opts.timefmt, 250) + components = [str(x) for x in components] + components = shorten_components_to(250 - len(root), components) + filepath = '%s%s' % (os.path.join(root, *components), ext) filedir = os.path.dirname(filepath) if not self.SUPPORTS_SUB_DIRS or not self.settings().use_subdirs: