<commit_before># -*- coding: utf-8 -*-

"""
Django-compatible Jinja2 Environment and helpers.

This module contains a subclass of ``jinja2.Environment`` and several other
functions which help use Jinja2 from within your Django projects.
"""

from functools import wraps
try:
    set
except NameError:
    from sets import Set as set

import jinja2


TEMPLATE_ENVIRONMENT = None


class Environment(jinja2.Environment):
    
    """An environment with decorators for filters, functions and tests."""
    
    def load(self, app_label, bundle_name, reload=False):
        """Load the specified bundle into this environment."""
        
        from djanjinja import loader
        
        # Returns the loaded bundle.
        return loader.load(
            app_label, bundle_name, environment=self, reload=reload)
    
    # pylint: disable-msg=C0111
    def adder(attribute, wrapper, name, docstring):
        
        """<commit_msg>Fixed major issue with environment bootstrapping.<commit_after># -*- coding: utf-8 -*-

"""
Django-compatible Jinja2 Environment and helpers.

This module contains a subclass of ``jinja2.Environment`` and several other
functions which help use Jinja2 from within your Django projects.
"""

from functools import wraps
try:
    set
except NameError:
    from sets import Set as set

import jinja2


TEMPLATE_ENVIRONMENT = None


class Environment(jinja2.Environment):
    
    """An environment with decorators for filters, functions and tests."""
    
    def __init__(self, *args, **kwargs):
        super(Environment, self).__init__(*args, **kwargs)
        # Add a `set()` attribute which stores the loaded bundles.
        self.loaded_bundles = set()
    
    def load(self, app_label, bundle_name, reload=False):
        """Load the specified bundle into this environment."""
        
        from djanjinja import loader
        
        # Returns the loaded bundle.
        return loader.load(
            app_label, bundle_name, environment=self, reload=reload)
    
    # pylint: disable-msg=C0111
    def adder(attribute, wrapper, name, docstring):
        
        """
{'fraction_non_alphanumeric': 0.08751182592242195, 'fraction_numerical': 0.00946073793755913, 'mean_word_length': 2.9239332096474953, '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': '1517367', 'n_tokens_mistral': 601, 'n_tokens_neox': 570, 'n_words': 203}