-def ufmt(uformat, *args):
- """Helper function to format a string by converting all its arguments to unicode"""
- if type(uformat) is not unicode:
- uformat = to_unicode(uformat)
- if len(args) == 1 and type(args[0]) is dict:
- arguments = to_unicode(args[0])
- else:
- nargs = []
- for arg in args:
- if type(arg) in (str, unicode, list, tuple, dict):
- nargs.append(to_unicode(arg))
- elif type(arg) not in (int, long, float):
- nargs.append(to_unicode(str(arg)))
- else:
- nargs.append(arg)
- arguments = tuple(nargs)
- formatted_string=""
- try:
- formatted_string = uformat % arguments
- #except UnicodeDecodeError:
- # print type(uformat), uformat
- # print type(arguments), arguments
- #raise
- except :
- pass
- return formatted_string
+#def from_unicode(ustring, encoding, errors='replace'):
+# """Try to encode a unicode string using encoding."""
+# try:
+# return ustring.encode(encoding)
+# except UnicodeError:
+# pass
+# return ustring.encode(encoding, errors)
+#
+#
+#def convert(content, encoding=None, errors='replace'):
+# """Convert content using encoding or default encoding if None."""
+# if type(content) not in (str, six.text_type):
+# content = six.text_type(content)
+# if type(content) == str:
+# content = to_unicode(content)
+# return from_unicode(content, encoding or get_encoding(), errors)
+#
+#
+#def ufmt(uformat, *args):
+# """Helper function to format a string by converting all its arguments to unicode"""
+# if type(uformat) is not six.text_type:
+# uformat = to_unicode(uformat)
+# if len(args) == 1 and type(args[0]) is dict:
+# arguments = to_unicode(args[0])
+# else:
+# nargs = []
+# for arg in args:
+# if type(arg) in (str, six.text_type, list, tuple, dict):
+# nargs.append(to_unicode(arg))
+# elif type(arg) not in (int, int, float):
+# nargs.append(to_unicode(str(arg)))
+# else:
+# nargs.append(arg)
+# arguments = tuple(nargs)
+# formatted_string=""
+# try:
+# formatted_string = uformat % arguments
+# #except UnicodeDecodeError:
+# # print type(uformat), uformat
+# # print type(arguments), arguments
+# #raise
+# except :
+# pass
+# return formatted_string