Example #1
0
 def wrapper(*argv, **argd):
     t_ansi    = GuessStringType.t_ansi
     t_unicode = GuessStringType.t_unicode
     v_types   = [ type(item) for item in argv ]
     v_types.extend( [ type(value) for (key, value) in compat.iteritems(argd) ] )
     if t_unicode in v_types:
         argv = list(argv)
         for index in compat.xrange(len(argv)):
             if v_types[index] == t_unicode:
                 argv[index] = t_ansi(argv[index])
         for key, value in argd.items():
             if type(value) == t_unicode:
                 argd[key] = t_ansi(value)
     return fn(*argv, **argd)
Example #2
0
 def wrapper(*argv, **argd):
     t_ansi = GuessStringType.t_ansi
     t_unicode = GuessStringType.t_unicode
     v_types = [type(item) for item in argv]
     v_types.extend(
         [type(value) for (key, value) in compat.iteritems(argd)])
     if t_unicode in v_types:
         argv = list(argv)
         for index in compat.xrange(len(argv)):
             if v_types[index] == t_unicode:
                 argv[index] = t_ansi(argv[index])
         for key, value in list(argd.items()):
             if type(value) == t_unicode:
                 argd[key] = t_ansi(value)
     return fn(*argv, **argd)
Example #3
0
    def __call__(self, *argv, **argd):

        # Shortcut to self.t_ansi
        t_ansi = self.t_ansi

        # Get the types of all arguments for the function
        v_types = [type(item) for item in argv]
        v_types.extend(
            [type(value) for (key, value) in compat.iteritems(argd)])

        # Get the appropriate function for the default type
        if self.t_default == t_ansi:
            fn = self.fn_ansi
        else:
            fn = self.fn_unicode

        # If at least one argument is a Unicode string...
        if self.t_unicode in v_types:

            # If al least one argument is an ANSI string,
            # convert all ANSI strings to Unicode
            if t_ansi in v_types:
                argv = list(argv)
                for index in compat.xrange(len(argv)):
                    if v_types[index] == t_ansi:
                        argv[index] = compat.str(argv[index])
                for (key, value) in list(argd.items()):
                    if type(value) == t_ansi:
                        argd[key] = compat.str(value)

            # Use the W version
            fn = self.fn_unicode

        # If at least one argument is an ANSI string,
        # but there are no Unicode strings...
        elif t_ansi in v_types:

            # Use the A version
            fn = self.fn_ansi

        # Call the function and return the result
        return fn(*argv, **argd)
Example #4
0
    def __call__(self, *argv, **argd):

        # Shortcut to self.t_ansi
        t_ansi    = self.t_ansi

        # Get the types of all arguments for the function
        v_types   = [ type(item) for item in argv ]
        v_types.extend( [ type(value) for (key, value) in compat.iteritems(argd) ] )

        # Get the appropriate function for the default type
        if self.t_default == t_ansi:
            fn = self.fn_ansi
        else:
            fn = self.fn_unicode

        # If at least one argument is a Unicode string...
        if self.t_unicode in v_types:

            # If al least one argument is an ANSI string,
            # convert all ANSI strings to Unicode
            if t_ansi in v_types:
                argv = list(argv)
                for index in compat.xrange(len(argv)):
                    if v_types[index] == t_ansi:
                        argv[index] = compat.unicode(argv[index])
                for (key, value) in argd.items():
                    if type(value) == t_ansi:
                        argd[key] = compat.unicode(value)

            # Use the W version
            fn = self.fn_unicode

        # If at least one argument is an ANSI string,
        # but there are no Unicode strings...
        elif t_ansi in v_types:

            # Use the A version
            fn = self.fn_ansi

        # Call the function and return the result
        return fn(*argv, **argd)