'''
Default helper functions
'''
from functools import wraps

from .escape import escape_html, escape_js
from .library import Library

register = Library()


def stringfilter(func):
    """
    Decorator for filters which should only receive unicode objects. The object
    passed as the first positional argument will be converted to a unicode
    object.
    """
    @wraps(func)
    def _dec(*args, **kwargs):
        if args:
            args = list(args)
            args[0] = str(args[0])
        return func(*args, **kwargs)

    return _dec


# add
# addslashes


@register.helper
@stringfilter
def addslashes(value):
    return value.replace('\\', '\\\\').replace('"', '\\"').replace("'", "\\'")

# capfirst


@register.helper
@stringfilter
def capfirst(value):
    return value and value[0].upper() + value[1:]

# center
# cut
# date
# default
# default_if_none
# dictsort
# dictsortreversed
# divisibleby
# escape
# escapejs

ESCAPES = {
    'html': escape_html,
    'js': escape_js,
}


@register.helper
@stringfilter
def escape(value, mode='html'):
    return ESCAPES[mode](value)

# filesizeformat
# first
# fix_ampersands
# floatformat
# force_escape
# get_digit
# iriencode
# join
# last
# length
# length_is
# linebreaks
# linebreaksbr
# linenumbers
# ljust
# lower
# make_list
# phone2numeric
# pluralize
# pprint
# random
# removetags
# rjust
# safe
# safeseq
# slice
# slugify
# stringformat
# striptags
# time
# timesince
# timeuntil
# title
# truncatechars
# truncatechars_html
# truncatewords
# truncatewords_html
# unordered_list
# upper
# urlencode
# urlize
# urlizetrunc
# wordcount
# wordwrap
# yesno

@@ -155,401 +155,8 @@
 )%0A%0A%0A
-def stringfilter(func):%0A    %22%22%22%0A    Decorator for filters which should only receive unicode objects. The object%0A    passed as the first positional argument will be converted to a unicode%0A    object.%0A    %22%22%22%0A    @wraps(func)%0A    def _dec(*args, **kwargs):%0A        if args:%0A            args = list(args)%0A            args%5B0%5D = str(args%5B0%5D)%0A        return func(*args, **kwargs)%0A%0A    return _dec%0A%0A%0A
 # ad
@@ -185,38 +185,24 @@
 ster.helper%0A
-@stringfilter%0A
 def addslash
@@ -318,38 +318,24 @@
 ster.helper%0A
-@stringfilter%0A
 def capfirst
@@ -571,16 +571,16 @@
 js,%0A%7D%0A%0A%0A
+
 @registe
@@ -592,22 +592,8 @@
 per%0A
-@stringfilter%0A
 def 

Remove the stringfilter decorator