<commit_before>"""Renderer for performing render operations for the pod."""

import traceback
import progressbar
from grow.common import progressbar_non
from grow.rendering import render_batch


class Error(Exception):
    """Base renderer error."""
    pass


class RenderErrors(Error):
    """Errors that occured during the rendering."""

    def __init__(self, message, errors):
        super(RenderErrors, self).__init__(message)
        self.errors = errors


class Renderer(object):
    """Handles the rendering and threading of the controllers."""

    @staticmethod
    def rendered_docs(pod, routes, use_threading=True):
        """Generate the rendered documents for the given routes."""
        with pod.profile.timer('renderer.Renderer.render_docs'):
            routes_len = len(routes)
            text = 'Building: %(value)d/{} (in %(time_elapsed).9s)'
            widgets = [progressbar.FormatLabel(text.format(routes_len))]
            progress = progressbar_non.create_progressbar(
                "Building pod...", widgets=widgets, max_value=routes_len)
            progress.start()

            def tick():
                """Tick the progress bar value."""
                progress.update(progress.value + 1)

            batches = render_batch.RenderBatches(
                pod.render_pool, pod.profile, tick=tick)

            for controller in Renderer.controller_generator(pod, routes):
                batches.add(controller)

            rendered_docs, render_errors = batches.render(
                use_threading=use_threading)
            progress.finish()

            if render_errors:
                for error in render_errors:
                    pod.logger.error(error.message)
                    pod.logger.error(error.err.message)
                    traceback.print_tb(error.err_tb)
                    pod.logger.error('')
                text = 'There were {} errors during rendering.'
                raise RenderErrors(text.format(
                    len(render_errors)), render_errors)
            return rendered_docs

    @staticmethod
    def controller_generator(pod, routes):
        """Generate the controllers for the given routes."""
        for path, route_info, _ in routes.nodes:
            yield pod.router.get_render_controller(path, route_info)
<commit_msg>Reverting the logger output for the rendering errors.<commit_after>"""Renderer for performing render operations for the pod."""

import traceback
import progressbar
from grow.common import progressbar_non
from grow.rendering import render_batch


class Error(Exception):
    """Base renderer error."""
    pass


class RenderErrors(Error):
    """Errors that occured during the rendering."""

    def __init__(self, message, errors):
        super(RenderErrors, self).__init__(message)
        self.errors = errors


class Renderer(object):
    """Handles the rendering and threading of the controllers."""

    @staticmethod
    def rendered_docs(pod, routes, use_threading=True):
        """Generate the rendered documents for the given routes."""
        with pod.profile.timer('renderer.Renderer.render_docs'):
            routes_len = len(routes)
            text = 'Building: %(value)d/{} (in %(time_elapsed).9s)'
            widgets = [progressbar.FormatLabel(text.format(routes_len))]
            progress = progressbar_non.create_progressbar(
                "Building pod...", widgets=widgets, max_value=routes_len)
            progress.start()

            def tick():
                """Tick the progress bar value."""
                progress.update(progress.value + 1)

            batches = render_batch.RenderBatches(
                pod.render_pool, pod.profile, tick=tick)

            for controller in Renderer.controller_generator(pod, routes):
                batches.add(controller)

            rendered_docs, render_errors = batches.render(
                use_threading=use_threading)
            progress.finish()

            if render_errors:
                for error in render_errors:
                    print error.message
                    print error.err.message
                    traceback.print_tb(error.err_tb)
                    print ''
                text = 'There were {} errors during rendering.'
                raise RenderErrors(text.format(
                    len(render_errors)), render_errors)
            return rendered_docs

    @staticmethod
    def controller_generator(pod, routes):
        """Generate the controllers for the given routes."""
        for path, route_info, _ in routes.nodes:
            yield pod.router.get_render_controller(path, route_info)

{'fraction_non_alphanumeric': 0.09280792420327304, 'fraction_numerical': 0.0008613264427217916, 'mean_word_length': 2.2665260196905765, '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': '4708340', 'n_tokens_mistral': 1195, 'n_tokens_neox': 1140, 'n_words': 307}