<commit_before># This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
import re

from django.views.decorators.cache import cache_page

from commonware.response.decorators import xframe_allow
from bs4 import BeautifulSoup

from lib import l10n_utils

from bedrock.legal_docs.views import LegalDocView, load_legal_doc


HN_PATTERN = re.compile(r'^h(\d)$')
HREF_PATTERN = re.compile(r'^https?\:\/\/www\.mozilla\.org')


def process_legal_doc(content):
    """
    Load a static Markdown file and return the document as a BeautifulSoup
    object for easier manipulation.

    :param content: HTML Content of the legal doc.
    """
    soup = BeautifulSoup(content)

    # Convert the site's full URLs to absolute paths
    for link in soup.find_all(href=HREF_PATTERN):
        link['href'] = HREF_PATTERN.sub('', link['href'])

    # Return the HTML fragment as a BeautifulSoup object
    return soup


class PrivacyDocView(LegalDocView):
    def get_legal_doc(self):
        doc = super(PrivacyDocView, self).get_legal_doc()
        doc['content'] = process_legal_doc(doc['content'])
        return doc


class FirefoxPrivacyDocView(PrivacyDocView):
    template_name = 'privacy/notices/base-notice-paragraphs.html'

    def get_legal_doc(self):
        doc = super(FirefoxPrivacyDocView, self).get_legal_doc()
        if len(doc['content'].select('.privacy-header-firefox')) > 0:<commit_msg>"No parser was explicitly specified" warning Fixed (#7812)<commit_after># This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
import re

from django.views.decorators.cache import cache_page

from commonware.response.decorators import xframe_allow
from bs4 import BeautifulSoup

from lib import l10n_utils

from bedrock.legal_docs.views import LegalDocView, load_legal_doc


HN_PATTERN = re.compile(r'^h(\d)$')
HREF_PATTERN = re.compile(r'^https?\:\/\/www\.mozilla\.org')


def process_legal_doc(content):
    """
    Load a static Markdown file and return the document as a BeautifulSoup
    object for easier manipulation.

    :param content: HTML Content of the legal doc.
    """
    soup = BeautifulSoup(content, "lxml")

    # Convert the site's full URLs to absolute paths
    for link in soup.find_all(href=HREF_PATTERN):
        link['href'] = HREF_PATTERN.sub('', link['href'])

    # Return the HTML fragment as a BeautifulSoup object
    return soup


class PrivacyDocView(LegalDocView):
    def get_legal_doc(self):
        doc = super(PrivacyDocView, self).get_legal_doc()
        doc['content'] = process_legal_doc(doc['content'])
        return doc


class FirefoxPrivacyDocView(PrivacyDocView):
    template_name = 'privacy/notices/base-notice-paragraphs.html'

    def get_legal_doc(self):
        doc = super(FirefoxPrivacyDocView, self).get_legal_doc()
        if len(doc['content'].select('.privacy-header-firefox')) > 0:
{'fraction_non_alphanumeric': 0.10317206023710349, 'fraction_numerical': 0.006408202499198975, 'mean_word_length': 3.916535433070866, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 1}, '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': '3185298', 'n_tokens_mistral': 1008, 'n_tokens_neox': 940, 'n_words': 283}