def subfn(pattern, format, string, *args, **kwargs):  # noqa A002
    """Wrapper for `subfn`."""

    flags = args[4] if len(args) > 4 else kwargs.get('flags', 0)
    is_replace = _is_replace(format)
    is_string = isinstance(format, (str, bytes))
    if is_replace and not format.use_format:
        raise ValueError("Compiled replace is not a format object!")

    pattern = compile_search(pattern, flags)
    rflags = FORMAT if is_string else 0
    return _regex.subn(
        pattern, (compile_replace(pattern, format, flags=rflags) if is_replace or is_string else format), string,
        *args, **kwargs
    )
def subfn ( pattern , format , string , * args , ** kwargs ) : flags = args [ 4 ] if len ( args ) > 4 else kwargs . get ( 'flags' , 0 ) is_replace = _is_replace ( format ) is_string = isinstance ( format , ( str , bytes ) ) if is_replace and not format . use_format : raise ValueError ( "Compiled replace is not a format object!" ) pattern = compile_search ( pattern , flags ) rflags = FORMAT if is_string else 0 return _regex . subn ( pattern , ( compile_replace ( pattern , format , flags = rflags ) if is_replace or is_string else format ) , string , * args , ** kwargs )
Wrapper for `subfn`.