Debian Codegraph @

tests/ansible/lib/filters/mitogen_tests.py

raw
1 from ansible.module_utils._text import to_text
2
3
4 try:
5 Unicode = unicode
6 except:
7 Unicode = str
8
9
10 def to_text(s):
11 """
12 Ensure the str or unicode `s` is unicode, and strip away any subclass. Also
13 works on lists.
14 """
15 if isinstance(s, list):
16 return [to_text(ss) for ss in s]
17 if not isinstance(s, Unicode):
18 s = to_text(s)
19 return Unicode(s)
20
21
22 class FilterModule(object):
23 def filters(self):
24 return {
25 'to_text': to_text,
26 }