# Path: lighty/utils.py
# def print_func(*args):
# def with_metaclass(meta, base=object):
#     def __init__(self, name, flag=True, optional=True, default=None, help='',
#                  type=str, nargs=1):
#     def __init__(self, program=None, description='', help=''):
#     def add_option(self, name, *args, **kwargs):
#     def add_argument(self, name, **kwargs):
#     def help_text(self):
#     def parse(self, args=None):
#     def _parse(self, args_for_parse):
# PY3 = sys.version_info[0] == 3
# class Argument(object):
# class CommandParser(object):
# 
# Path: lighty/templates/context.py
# def resolve(var_name, context):
#     if '.' in var_name:
#         fields = var_name.split('.')
#         return reduce(get_field, [get_value(fields[0], context)] + fields[1:])
#     return get_value(var_name, context)
# 
# Path: lighty/templates/loaders.py
# class TemplateLoader(object):
#     '''Class fot managing templates
#     '''
# 
#     def __init__(self):
#         '''Create new template loader
#         '''
#         super(TemplateLoader, self).__init__()
#         # Create new templates dictionary
#         self.templates = {}
# 
#     def register(self, name, template):
#         '''Add loaded or generated template
#         '''
#         self.templates[name] = template
# 
#     def get_template(self, name):
#         '''Get template by name
#         '''
#         if name not in self.templates:
#             raise Exception("Template '%s' was not found" % name)
#         return self.templates[name]
# 
# 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/tag.py
# VARIABLE = 0
# STRING = 1
# NUMBER = 2
# def parse_token(token):
#     def __init__(self):
#     def register(self, name, tag, is_block_tag=False, context_required=False,
#                  template_required=False, loader_required=False,
#                  is_lazy_tag=True):
#     def is_tag_exists(self, name):
#     def is_block_tag(self, name):
#     def is_lazy_tag(self, name):
#     def execute(self, name, token, context, block, template, loader):
# class TagManager(object):


from collections import deque
from functools import reduce
from decimal import Decimal
from ..utils import StringIO
from .context import resolve
from .loaders import TemplateLoader
from .filter import filter_manager
from .tag import tag_manager, parse_token
        filters = []
        variable = parts[0]
        for token in parts[1:]:
            if ':' in token:
                parsed = token.split(':')
                if len(parsed) > 1:
                    filter, args_token = parsed
                    args, types = parse_token(args_token)
                else:
                    filter = parsed
                    args, types = (), ()
            else:
                filter = token
                args, types = (), ()
            filters.append((filter, args, types))

        def apply_filters(context):
            def apply_filter(value, pair):
                filter, args, types = pair
                return filter_manager.apply(filter, value, args, types,
                                            context)
            if variable[0] == '"' or variable[0] == "'":
                if variable[0] == variable[-1]:
                    value_with_filters = [variable[1:-1]] + filters
                else:
                    raise Exception('Template filter syntax error')
            else:
                try:
                    value_with_filters = [Decimal(variable)] + filters
                except:

# Path: lighty/utils.py
# def print_func(*args):
# def with_metaclass(meta, base=object):
#     def __init__(self, name, flag=True, optional=True, default=None, help='',
#                  type=str, nargs=1):
#     def __init__(self, program=None, description='', help=''):
#     def add_option(self, name, *args, **kwargs):
#     def add_argument(self, name, **kwargs):
#     def help_text(self):
#     def parse(self, args=None):
#     def _parse(self, args_for_parse):
# PY3 = sys.version_info[0] == 3
# class Argument(object):
# class CommandParser(object):
# 
# Path: lighty/templates/context.py
# def resolve(var_name, context):
#     if '.' in var_name:
#         fields = var_name.split('.')
#         return reduce(get_field, [get_value(fields[0], context)] + fields[1:])
#     return get_value(var_name, context)
# 
# Path: lighty/templates/loaders.py
# class TemplateLoader(object):
#     '''Class fot managing templates
#     '''
# 
#     def __init__(self):
#         '''Create new template loader
#         '''
#         super(TemplateLoader, self).__init__()
#         # Create new templates dictionary
#         self.templates = {}
# 
#     def register(self, name, template):
#         '''Add loaded or generated template
#         '''
#         self.templates[name] = template
# 
#     def get_template(self, name):
#         '''Get template by name
#         '''
#         if name not in self.templates:
#             raise Exception("Template '%s' was not found" % name)
#         return self.templates[name]
# 
# 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/tag.py
# VARIABLE = 0
# STRING = 1
# NUMBER = 2
# def parse_token(token):
#     def __init__(self):
#     def register(self, name, tag, is_block_tag=False, context_required=False,
#                  template_required=False, loader_required=False,
#                  is_lazy_tag=True):
#     def is_tag_exists(self, name):
#     def is_block_tag(self, name):
#     def is_lazy_tag(self, name):
#     def execute(self, name, token, context, block, template, loader):
# class TagManager(object):


# Path: lighty/templates/template.py
from collections import deque
from functools import reduce
from decimal import Decimal
from ..utils import StringIO
from .context import resolve
from .loaders import TemplateLoader
from .filter import filter_manager
from .tag import tag_manager, parse_token

        filters = []
        variable = parts[0]
        for token in parts[1:]:
            if ':' in token:
                parsed = token.split(':')
                if len(parsed) > 1:
                    filter, args_token = parsed
                    args, types = parse_token(args_token)
                else:
                    filter = parsed
                    args, types = (), ()
            else:
                filter = token
                args, types = (), ()
            filters.append((filter, args, types))

        def apply_filters(context):
            def apply_filter(value, pair):
                filter, args, types = pair
                return filter_manager.apply(filter, value, args, types,
                                            context)
            if variable[0] == '"' or variable[0] == "'":
                if variable[0] == variable[-1]:
                    value_with_filters = [variable[1:-1]] + filters
                else:
                    raise Exception('Template filter syntax error')
            else:
                try:
                    value_with_filters = [Decimal(variable)] + filters
                except:

                    value_with_filters = [resolve(variable, context)] + filters