# Path: lighty/templates/filter.py
# class FilterManager(object):
#     def __init__(self):
#     def is_filter_exists(self, name):
#     def register(self, filter):
#     def apply(self, filter, value, args, arg_types, context):


from decimal import Decimal, ROUND_DOWN, ROUND_HALF_UP
from functools import reduce
from operator import itemgetter
from .filter import filter_manager
import random as random_module
    result = do_float_format(value.copy_abs(), digits, ROUND_DOWN)
    result = str(result.copy_sign(value))
    if format[0] == '-':
        return result.rstrip('0')
    return result
filter_manager.register(floatformat)


def floatround(raw_value, format="0"):
    '''Round a float value according to math rules

    Lets:
        a = '12.45'
    Then:
        >>> print floatround(a)
        12
        >>> print floatround(a, '1')
        12.5
    '''
    value, digits = float_format_args_parse('floatround', raw_value, format)
    return do_float_format(value, digits, ROUND_HALF_UP)
filter_manager.register(floatround)

# Strings


def addslashes(value):
    '''Add a slashes to string
    '''
    return value.replace('\\', '\\\\').replace('"', '\\"').replace("'", "\\'")

# Path: lighty/templates/filter.py
# class FilterManager(object):
#     def __init__(self):
#     def is_filter_exists(self, name):
#     def register(self, filter):
#     def apply(self, filter, value, args, arg_types, context):


# Path: lighty/templates/templatefilters.py
from decimal import Decimal, ROUND_DOWN, ROUND_HALF_UP
from functools import reduce
from operator import itemgetter
from .filter import filter_manager
import random as random_module

    result = do_float_format(value.copy_abs(), digits, ROUND_DOWN)
    result = str(result.copy_sign(value))
    if format[0] == '-':
        return result.rstrip('0')
    return result
filter_manager.register(floatformat)


def floatround(raw_value, format="0"):
    '''Round a float value according to math rules

    Lets:
        a = '12.45'
    Then:
        >>> print floatround(a)
        12
        >>> print floatround(a, '1')
        12.5
    '''
    value, digits = float_format_args_parse('floatround', raw_value, format)
    return do_float_format(value, digits, ROUND_HALF_UP)
filter_manager.register(floatround)

# Strings


def addslashes(value):
    '''Add a slashes to string
    '''
    return value.replace('\\', '\\\\').replace('"', '\\"').replace("'", "\\'")

filter_manager.register(addslashes)