From c0bc2451dddf6be8f6f14769e2f1da8dbdaecfac Mon Sep 17 00:00:00 2001 From: Jason Gerard DeRose Date: Fri, 23 Jan 2009 09:55:38 -0700 Subject: Fixed another small CLI decoding problem (multivalue args in a tuple now work) --- ipalib/cli.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'ipalib/cli.py') diff --git a/ipalib/cli.py b/ipalib/cli.py index 26828e5d..827a12d7 100644 --- a/ipalib/cli.py +++ b/ipalib/cli.py @@ -110,19 +110,19 @@ class textui(backend.Backend): def __get_encoding(self, stream): assert stream in (sys.stdin, sys.stdout) if stream.encoding is None: - if stream.isatty(): - return sys.getdefaultencoding() return 'UTF-8' return stream.encoding - def decode(self, str_buffer): + def decode(self, value): """ Decode text from stdin. """ - if type(str_buffer) is str: + if type(value) is str: encoding = self.__get_encoding(sys.stdin) - return str_buffer.decode(encoding) - return str_buffer + return value.decode(encoding) + elif type(value) in (list, tuple): + return tuple(self.decode(v) for v in value) + return value def encode(self, unicode_text): """ -- cgit