# Path: parm/_compat.py
# PY3 = sys.version_info[0] == 3
# PY2 = sys.version_info[0] == 2
# PY26 = sys.version_info[0:2] == (2, 6)
# PYPY = hasattr(sys, 'pypy_translation_info')
#     def reraise(tp, value, tb=None):
#     def u(s, encoding='utf8'):
#     def b(s):
#     def implements_iterator(cls):
#     def python_2_unicode_compatible(cls):
#     def u(s, encoding='utf8'):
#     def b(s, encoding='utf8'):
#     def exec_(code, globs=None, locs=None):
#     def next(it):
# def with_metaclass(meta, *bases):
#         def __new__(cls, name, this_bases, d):
# def import_(module, objects=None, via=None):
#     class metaclass(meta):


from ._compat import exec_, u, string_types, open
import re
import os
import io
import cgi
        return self._run(code, filename or 'template')
        
    def _run(self, code, filename):
        def f(_vars, _env):
            def defined(v, default=None):
                _v = default
                if v in _vars:
                    _v = _vars[v]
                elif v in _env:
                    _v = _env[v]
                return _v
            return defined

        e = {}
        if isinstance(self.env, Context):
            new_e = self.env.to_dict()
        else:
            new_e = self.env
        e.update(new_e)
        e.update(self.vars)
        out = Out()
        e['out'] = out
        e['Out'] = Out
        e['xml'] = out.xml
        e['_vars'] = self.vars
        e['defined'] = f(self.vars, self.env)
        e['_env'] = e
        
        e.update(self.exec_env)
        

# Path: parm/_compat.py
# PY3 = sys.version_info[0] == 3
# PY2 = sys.version_info[0] == 2
# PY26 = sys.version_info[0:2] == (2, 6)
# PYPY = hasattr(sys, 'pypy_translation_info')
#     def reraise(tp, value, tb=None):
#     def u(s, encoding='utf8'):
#     def b(s):
#     def implements_iterator(cls):
#     def python_2_unicode_compatible(cls):
#     def u(s, encoding='utf8'):
#     def b(s, encoding='utf8'):
#     def exec_(code, globs=None, locs=None):
#     def next(it):
# def with_metaclass(meta, *bases):
#         def __new__(cls, name, this_bases, d):
# def import_(module, objects=None, via=None):
#     class metaclass(meta):


# Path: parm/template.py
from ._compat import exec_, u, string_types, open
import re
import os
import io
import cgi

        return self._run(code, filename or 'template')
        
    def _run(self, code, filename):
        def f(_vars, _env):
            def defined(v, default=None):
                _v = default
                if v in _vars:
                    _v = _vars[v]
                elif v in _env:
                    _v = _env[v]
                return _v
            return defined

        e = {}
        if isinstance(self.env, Context):
            new_e = self.env.to_dict()
        else:
            new_e = self.env
        e.update(new_e)
        e.update(self.vars)
        out = Out()
        e['out'] = out
        e['Out'] = Out
        e['xml'] = out.xml
        e['_vars'] = self.vars
        e['defined'] = f(self.vars, self.env)
        e['_env'] = e
        
        e.update(self.exec_env)
        

        if isinstance(code, string_types):