From 386625f9570f19d0b4b87659eb1fa2ccd1b756f5 Mon Sep 17 00:00:00 2001 From: John Schember Date: Wed, 6 Jan 2010 20:13:00 -0500 Subject: [PATCH 1/4] Device Config: Use default save template when none is specified. --- src/calibre/devices/usbms/deviceconfig.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/calibre/devices/usbms/deviceconfig.py b/src/calibre/devices/usbms/deviceconfig.py index 4e632433b8..925347ef79 100644 --- a/src/calibre/devices/usbms/deviceconfig.py +++ b/src/calibre/devices/usbms/deviceconfig.py @@ -64,7 +64,7 @@ class DeviceConfig(object): ec = None proxy['extra_customization'] = ec st = unicode(config_widget.opt_save_template.text()) - proxy['save_template'] = st + proxy['save_template'] = st if st else cls._default_save_template() @classmethod def settings(cls): From 4b3059e9794240b57bcc2cf869325d426e37dd44 Mon Sep 17 00:00:00 2001 From: John Schember Date: Thu, 7 Jan 2010 07:21:18 -0500 Subject: [PATCH 2/4] USBMS: Use default send template when device specific one is not present. --- src/calibre/devices/usbms/device.py | 2 +- src/calibre/devices/usbms/deviceconfig.py | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/calibre/devices/usbms/device.py b/src/calibre/devices/usbms/device.py index e852ae7f62..f01133c301 100644 --- a/src/calibre/devices/usbms/device.py +++ b/src/calibre/devices/usbms/device.py @@ -805,7 +805,7 @@ class Device(DeviceConfig, DevicePlugin): break settings = self.settings() - template = settings.save_template + template = self.save_template() use_subdirs = self.SUPPORTS_SUB_DIRS and settings.use_subdirs fname = sanitize(fname) diff --git a/src/calibre/devices/usbms/deviceconfig.py b/src/calibre/devices/usbms/deviceconfig.py index 925347ef79..a8220261f3 100644 --- a/src/calibre/devices/usbms/deviceconfig.py +++ b/src/calibre/devices/usbms/deviceconfig.py @@ -64,12 +64,20 @@ class DeviceConfig(object): ec = None proxy['extra_customization'] = ec st = unicode(config_widget.opt_save_template.text()) - proxy['save_template'] = st if st else cls._default_save_template() + proxy['save_template'] = st @classmethod def settings(cls): return cls._config().parse() + @classmethod + def save_template(cls): + st = cls.settings().save_template + if st: + return st + else: + return cls._default_save_template() + @classmethod def customization_help(cls, gui=False): return cls.HELP_MESSAGE From 567ecc4256125fb6becb71b4aab8c98230904d18 Mon Sep 17 00:00:00 2001 From: John Schember Date: Thu, 7 Jan 2010 18:26:15 -0500 Subject: [PATCH 3/4] RTF Output: Replace output encoding with user defined encoding. --- src/calibre/ebooks/rtf/output.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/calibre/ebooks/rtf/output.py b/src/calibre/ebooks/rtf/output.py index 5738b7e6f4..0fc9b3cbb0 100644 --- a/src/calibre/ebooks/rtf/output.py +++ b/src/calibre/ebooks/rtf/output.py @@ -30,7 +30,7 @@ class RTFOutput(OutputFormatPlugin): out_stream.seek(0) out_stream.truncate() - out_stream.write(content.encode('ascii', 'replace')) + out_stream.write(content.encode(opts.output_encoding, 'replace')) if close: out_stream.close() From bf0659d6918c7f7c043764ad8d4f2c1b3fd1dd4f Mon Sep 17 00:00:00 2001 From: John Schember Date: Thu, 7 Jan 2010 18:39:52 -0500 Subject: [PATCH 4/4] Revert stupid changes. --- src/calibre/ebooks/rtf/output.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/calibre/ebooks/rtf/output.py b/src/calibre/ebooks/rtf/output.py index 0fc9b3cbb0..5738b7e6f4 100644 --- a/src/calibre/ebooks/rtf/output.py +++ b/src/calibre/ebooks/rtf/output.py @@ -30,7 +30,7 @@ class RTFOutput(OutputFormatPlugin): out_stream.seek(0) out_stream.truncate() - out_stream.write(content.encode(opts.output_encoding, 'replace')) + out_stream.write(content.encode('ascii', 'replace')) if close: out_stream.close()