From 313a760feded62ba39910bf36fc4d62b56d07858 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Sat, 18 Jul 2009 09:47:46 -0400 Subject: [PATCH] Allow external override of libbe.encoding.get_encoding(). The previous procmail encoding fix failed, because the becommand execution checks libbe.encoding.get_encoding() on it's own, and got the procmail encoding. This one works. --- interfaces/email/interactive/be-handle-mail | 5 +++-- libbe/encoding.py | 4 ++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/interfaces/email/interactive/be-handle-mail b/interfaces/email/interactive/be-handle-mail index aa0c96a..42d85ac 100755 --- a/interfaces/email/interactive/be-handle-mail +++ b/interfaces/email/interactive/be-handle-mail @@ -46,8 +46,9 @@ _THIS_DIR = os.path.abspath(os.path.dirname(__file__)) BE_DIR = _THIS_DIR LOGPATH = os.path.join(_THIS_DIR, "be-handle-mail.log") LOGFILE = None -#ENCODING = libbe.encoding.get_encoding() -ENCODING = "utf-8" + +libbe.encoding.ENCODING = "utf-8" # force default encoding +ENCODING = libbe.encoding.get_encoding() ALLOWED_COMMANDS = ["new", "comment", "list", "show", "help"] diff --git a/libbe/encoding.py b/libbe/encoding.py index d603602..4af864e 100644 --- a/libbe/encoding.py +++ b/libbe/encoding.py @@ -19,11 +19,15 @@ import locale import sys import doctest +ENCODING = None # override get_encoding() output by setting this + def get_encoding(): """ Guess a useful input/output/filesystem encoding... Maybe we need seperate encodings for input/output and filesystem? Hmm... """ + if ENCODING != None: + return ENCODING encoding = locale.getpreferredencoding() or sys.getdefaultencoding() if sys.platform != 'win32' or sys.version_info[:2] > (2, 3): encoding = locale.getlocale(locale.LC_TIME)[1] or encoding -- 2.26.2