<commit_before>#!/usr/bin/env python
from __future__ import print_function
from __future__ import unicode_literals

import argparse
import codecs
import logging
import pypuppetdb
import jinja2

log = logging.getLogger('puppetdb_stencil')

METAPARAMS = ('require', 'before', 'subscribe', 'notify', 'audit', 'loglevel',
        'noop', 'schedule', 'stage', 'alias', 'tag')

# Allow templates from anywhere on the filesystem
loader = jinja2.FileSystemLoader(['.', '/'])
environment = jinja2.Environment(trim_blocks=True, lstrip_blocks=True,
        loader=loader,
        extensions=['jinja2.ext.with_', 'jinja2.ext.loopcontrols'])

def render_resources(db, resource_type, template_names):
    resources = db.resources(resource_type)
    try:
        template = environment.select_template(templates)
    except jinja2.TemplatesNotFound:
        log.error('No template found for {0}'.format(resource_type))
    else:
        return template.render(resource_type=resource_type,
            resources=resources, metaparams=METAPARAMS)
<commit_msg>Make pep8 happy<commit_after>#!/usr/bin/env python
from __future__ import print_function
from __future__ import unicode_literals

import argparse
import logging
import pypuppetdb
import jinja2

log = logging.getLogger('puppetdb_stencil')

METAPARAMS = ('require', 'before', 'subscribe', 'notify', 'audit', 'loglevel',
        'noop', 'schedule', 'stage', 'alias', 'tag')

# Allow templates from anywhere on the filesystem
loader = jinja2.FileSystemLoader(['.', '/'])
environment = jinja2.Environment(trim_blocks=True, lstrip_blocks=True,
        loader=loader,
        extensions=['jinja2.ext.with_', 'jinja2.ext.loopcontrols'])


def render_resources(db, resource_type, template_names):
    resources = db.resources(resource_type)
    try:
        template = environment.select_template(templates)
    except jinja2.TemplatesNotFound:
        log.error('No template found for {0}'.format(resource_type))
    else:
        return template.render(resource_type=resource_type,
            resources=resources, metaparams=METAPARAMS)

{'fraction_non_alphanumeric': 0.11577424023154848, 'fraction_numerical': 0.00723589001447178, 'mean_word_length': 4.825842696629214, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6844808', 'n_tokens_mistral': 646, 'n_tokens_neox': 614, 'n_words': 140}