def normalize(arg=None):
    """Normalizes an argument for signing purpose.

    This is used for normalizing the arguments of RPC method calls.

    :param arg: The argument to normalize

    :return: A string representating the normalized argument.

    .. doctest::

     >>> from cloud.rpc import normalize
     >>> normalize(['foo', 42, 'bar'])
     'foo42bar'
     >>> normalize({'yellow': 1, 'red': 2, 'pink' : 3})
     'pink3red2yellow1'
     >>> normalize(['foo', 42, {'yellow': 1, 'red': 2, 'pink' : 3}, 'bar'])
     'foo42pink3red2yellow1bar'
     >>> normalize(None)
     ''
     >>> normalize([None, 1,2])
     '12'
     >>> normalize({2: [None, 1,2], 3: None, 4:5})
     '212345'
    """
    res = ''

    t_arg = type(arg)
    if t_arg in (list, tuple):
        for i in arg:
            res += normalize(i)
    elif t_arg is dict:
        keys = arg.keys()
        keys.sort()
        for key in keys:
            res += '%s%s' % (normalize(key), normalize(arg[key]))
    elif t_arg is unicode:
        res = arg.encode('utf8')
    elif t_arg is bool:
        res = 'true' if arg else 'false'
    elif arg != None:
        res = str(arg)

    return res
Normalizes an argument for signing purpose.

    This is used for normalizing the arguments of RPC method calls.

    :param arg: The argument to normalize

    :return: A string representating the normalized argument.

    .. doctest::

     >>> from cloud.rpc import normalize
     >>> normalize(['foo', 42, 'bar'])
     'foo42bar'
     >>> normalize({'yellow': 1, 'red': 2, 'pink' : 3})
     'pink3red2yellow1'
     >>> normalize(['foo', 42, {'yellow': 1, 'red': 2, 'pink' : 3}, 'bar'])
     'foo42pink3red2yellow1bar'
     >>> normalize(None)
     ''
     >>> normalize([None, 1,2])
     '12'
     >>> normalize({2: [None, 1,2], 3: None, 4:5})
     '212345'