From d50089ca9f838beccfc7ce633d64267f47287373 Mon Sep 17 00:00:00 2001 From: Toshio Kuratomi Date: Mon, 2 Feb 2015 18:28:47 -0800 Subject: [PATCH] Add a function to change output from a str to unicode --- v2/ansible/utils/unicode.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/v2/ansible/utils/unicode.py b/v2/ansible/utils/unicode.py index 06ebc18c020..b2fcf65161b 100644 --- a/v2/ansible/utils/unicode.py +++ b/v2/ansible/utils/unicode.py @@ -241,3 +241,8 @@ def to_bytes(obj, encoding='utf-8', errors='replace', nonstring=None): raise TypeError('nonstring value, %(param)s, is not set to a valid' ' action' % {'param': nonstring}) + +# force the return value of a function to be unicode. Use with partial to +# ensure that a filter will return unicode values. +def unicode_wrap(func, *args, **kwargs): + return to_unicode(func(*args, **kwargs), nonstring='passthru')