<s> '''<STR_LIT>''' <EOL> from __future__ import absolute_import <EOL> import imp <EOL> from salt . ext . six import exec_ <EOL> from salt . utils import pydsl <EOL> from salt . utils . pydsl import PyDslError <EOL> from salt . exceptions import SaltRenderError <EOL> __all__ = [ '<STR_LIT>' ] <EOL> def render ( template , saltenv = '<STR_LIT>' , sls = '<STR_LIT>' , tmplpath = None , rendered_sls = None , ** kws ) : <EOL> mod = imp . new_module ( sls ) <EOL> mod . __name__ = sls <EOL> mod . __deepcopy__ = lambda x : mod <EOL> dsl_sls = pydsl . Sls ( sls , saltenv , rendered_sls ) <EOL> mod . __dict__ . update ( <EOL> __pydsl__ = dsl_sls , <EOL> include = _wrap_sls ( dsl_sls . include ) , <EOL> extend = _wrap_sls ( dsl_sls . extend ) , <EOL> state = _wrap_sls ( dsl_sls . state ) , <EOL> __salt__ = __salt__ , <EOL> __grains__ = __grains__ , <EOL> __opts__ = __opts__ , <EOL> __pillar__ = __pillar__ , <EOL> __env__ = saltenv , <EOL> __sls__ = sls , <EOL> __file__ = tmplpath , <EOL> ** kws ) <EOL> dsl_sls . get_render_stack ( ) . append ( dsl_sls ) <EOL> exec_ ( template . read ( ) , mod . __dict__ ) <EOL> highstate = dsl_sls . to_highstate ( mod ) <EOL> dsl_sls . get_render_stack ( ) . pop ( ) <EOL> return highstate <EOL> def _wrap_sls ( method ) : <EOL> def _sls_method ( * args , ** kws ) : <EOL> sls = pydsl . Sls . get_render_stack ( ) [ - <NUM_LIT:1> ] <EOL> try : <EOL> return getattr ( sls , method . __name__ ) ( * args , ** kws ) <EOL> except PyDslError as exc : <EOL> raise SaltRenderError ( exc ) <EOL> return _sls_method </s>
