<commit_before>#vim: set encoding=utf-8
from django.views.generic.base import TemplateView

from regulations.generator import generator
from regulations.generator.html_builder import HTMLBuilder
from regulations.generator.node_types import EMPTYPART, REGTEXT
from regulations.views import utils
from regulations.views.partial import generate_html
from regulations.generator.layers.diff_applier import DiffApplier


class PartialSectionDiffView(TemplateView):
    """ A diff view of a partial section. """
    template_name = 'regulation-content.html'

    def get_context_data(self, **kwargs):
        context = super(
            PartialSectionDiffView, self).get_context_data(**kwargs)

        label_id = context['label_id']
        older = context['version']
        newer = context['newer_version']

        tree = generator.get_tree_paragraph(label_id, older)

        appliers = utils.handle_specified_layers('', label_id, older)

        reg = label_id.split('-')[0]
        appliers += (generator.get_diff_applier(reg, older, newer),)

        builder = HTMLBuilder(*appliers)
        builder.tree = tree
        builder.generate_html()

        # Add a tree layer to account for subpart if this is regtext
        if builder.tree['node_type'] == REGTEXT:
            child_of_root = {
                'node_type': EMPTYPART,
                'children': [builder.tree]}
        context['tree'] = {'children': [child_of_root]}
        #context['navigation'] = self.section_navigation(
        #    context['label_id'], context['version'])
        return context<commit_msg>Removing unused code<commit_after>#vim: set encoding=utf-8
from django.views.generic.base import TemplateView

from regulations.generator import generator
from regulations.generator.html_builder import HTMLBuilder
from regulations.generator.node_types import EMPTYPART, REGTEXT
from regulations.views import utils
from regulations.views.partial import generate_html
from regulations.generator.layers.diff_applier import DiffApplier


class PartialSectionDiffView(TemplateView):
    """ A diff view of a partial section. """
    template_name = 'regulation-content.html'

    def get_context_data(self, **kwargs):
        context = super(
            PartialSectionDiffView, self).get_context_data(**kwargs)

        label_id = context['label_id']
        older = context['version']
        newer = context['newer_version']

        tree = generator.get_tree_paragraph(label_id, older)

        appliers = utils.handle_specified_layers('', label_id, older)

        reg = label_id.split('-')[0]
        appliers += (generator.get_diff_applier(reg, older, newer),)

        builder = HTMLBuilder(*appliers)
        builder.tree = tree
        builder.generate_html()

        # Add a tree layer to account for subpart if this is regtext
        if builder.tree['node_type'] == REGTEXT:
            child_of_root = {
                'node_type': EMPTYPART,
                'children': [builder.tree]}
        context['tree'] = {'children': [child_of_root]}
        return context
{'fraction_non_alphanumeric': 0.09911678115799803, 'fraction_numerical': 0.0013084723585214263, 'mean_word_length': 3.2889200561009817, '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': '7570904', 'n_tokens_mistral': 836, 'n_tokens_neox': 819, 'n_words': 203}