<s> from jinja2 import Template <EOL> from config_constants import Constants <EOL> def create ( ctx , policy_types , policy_triggers , groups , config_template ) : <EOL> streams = [ ] <EOL> for group_name , group in groups . items ( ) : <EOL> for policy_name , policy in group [ '<STR_LIT>' ] . items ( ) : <EOL> template = Template ( policy_types [ policy [ '<STR_LIT:type>' ] ] [ '<STR_LIT:source>' ] ) <EOL> metadata = { <EOL> '<STR_LIT>' : group_name , <EOL> '<STR_LIT>' : policy_name , <EOL> '<STR_LIT>' : policy [ '<STR_LIT:type>' ] , <EOL> '<STR_LIT>' : policy [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : group [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : ctx <EOL> } <EOL> template_vars = policy [ '<STR_LIT>' ] <EOL> template_vars [ '<STR_LIT>' ] = metadata <EOL> template_vars [ '<STR_LIT>' ] = Constants <EOL> data = template . render ( ** template_vars ) <EOL> streams . append ( { <EOL> '<STR_LIT:data>' : data , <EOL> '<STR_LIT>' : metadata <EOL> } ) <EOL> return Template ( config_template ) . render ( <EOL> streams = streams , <EOL> policy_triggers = policy_triggers , <EOL> ctx = ctx , <EOL> constants = Constants <EOL> ) </s>
