(func, version_specs, patch=False)
return outer
@param func: the function to replace the original function.
    @param version_specs: a list of version_spec.
    if any of the version_specs matched, the original func will be replaced.
    example of version_spec:
    {'client': 'ios', 'gte': (2, 10)} or
    {'client': 'android', 'gt': (1, 12), 'lte': (2, 10)}
def replace_func_with(func, version_specs, patch=False):
    '''
    @param func: the function to replace the original function.
    @param version_specs: a list of version_spec.
    if any of the version_specs matched, the original func will be replaced.
    example of version_spec:
    {'client': 'ios', 'gte': (2, 10)} or
    {'client': 'android', 'gt': (1, 12), 'lte': (2, 10)} '''

    def outer(orig_func):
        @wraps(orig_func)
        def decorated_function(*args, **kwargs):
            version = (g.get('version_major'), g.get('version_minor'))
            client = g.get('client')
            if not any(match_spec(client, version, spec)
                       for spec in version_specs):
                return orig_func(*args, **kwargs)

            if isinstance(func, basestring):
                new_func = get_func_from_str(func, args)
                new_args = args[1:]
            else:
                new_func = func
                new_args = args
            if not new_func:
                return orig_func(*args, **kwargs)
            if patch:
                return new_func(orig_func(*args, **kwargs))
            return new_func(*new_args, **kwargs)
        return decorated_function
    return outer
def replace_func_with ( func , version_specs , patch = False ) : def outer ( orig_func ) : @ wraps ( orig_func ) def decorated_function ( * args , * * kwargs ) : version = ( g . get ( 'version_major' ) , g . get ( 'version_minor' ) ) client = g . get ( 'client' ) if not any ( match_spec ( client , version , spec ) for spec in version_specs ) : return orig_func ( * args , * * kwargs ) if isinstance ( func , basestring ) : new_func = get_func_from_str ( func , args ) new_args = args [ 1 : ] else : new_func = func new_args = args if not new_func : return orig_func ( * args , * * kwargs ) if patch : return new_func ( orig_func ( * args , * * kwargs ) ) return new_func ( * new_args , * * kwargs ) return decorated_function return outer