From 60c3a5c5f8fe510effc107bcdb115ac117b22fcf Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 28 Sep 2009 17:02:47 -0600 Subject: [PATCH] Remove trailing periods from path components when sending books to devices. Fixes #3475 (No books in Collection on Sony PRS-300) --- src/calibre/devices/usbms/device.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/calibre/devices/usbms/device.py b/src/calibre/devices/usbms/device.py index 817167741e..97b4b3ec19 100644 --- a/src/calibre/devices/usbms/device.py +++ b/src/calibre/devices/usbms/device.py @@ -711,6 +711,14 @@ class Device(DeviceConfig, DevicePlugin): 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) filedir = os.path.dirname(filepath)