<commit_before>"""Form widgets used by the CMS."""
import re
import string

from django import forms
from django.conf import settings
from django.contrib.auth.forms import PasswordChangeForm, AdminPasswordChangeForm
from django.contrib.staticfiles.storage import staticfiles_storage
from django.core.exceptions import ValidationError
from django.utils.safestring import mark_safe

from cms import debug

try:
    import json
except:
    from django.utils import simplejson as json


class HtmlWidget(forms.Textarea):

    """A textarea that is converted into a Redactor editor."""

    def __init__(self, *args, **kwargs):
        """Initializes the HtmlWidget."""
        super(HtmlWidget, self).__init__(*args, **kwargs)

    @debug.print_exc
    def get_media(self):
        """Returns the media used by the widget."""
        js = [
            staticfiles_storage.url("cms/js/jquery.cms.js"),
            staticfiles_storage.url("cms/js/jquery.cookie.js"),
            staticfiles_storage.url("pages/js/jquery.cms.pages.js"),
            staticfiles_storage.url("cms/js/redactor/redactor.js"),
        ] + [
            staticfiles_storage.url('cms/js/redactor/plugins/{plugin}/{plugin}.js'.format(plugin=plugin))
            for plugin in getattr(settings, 'REDACTOR_OPTIONS', {}).get('plugins', [])
        ]

        css = {
            "all": [<commit_msg>Modify imports in `cms.forms`.<commit_after>from django import forms
from django.conf import settings
from django.contrib.auth.forms import PasswordChangeForm, AdminPasswordChangeForm
from django.contrib.staticfiles.storage import staticfiles_storage
from django.core.exceptions import ValidationError
from django.utils.safestring import mark_safe

from cms import debug

import json
import re
import string


class HtmlWidget(forms.Textarea):

    """A textarea that is converted into a Redactor editor."""

    def __init__(self, *args, **kwargs):
        """Initializes the HtmlWidget."""
        super(HtmlWidget, self).__init__(*args, **kwargs)

    @debug.print_exc
    def get_media(self):
        """Returns the media used by the widget."""
        js = [
            staticfiles_storage.url("cms/js/jquery.cms.js"),
            staticfiles_storage.url("cms/js/jquery.cookie.js"),
            staticfiles_storage.url("pages/js/jquery.cms.pages.js"),
            staticfiles_storage.url("cms/js/redactor/redactor.js"),
        ] + [
            staticfiles_storage.url('cms/js/redactor/plugins/{plugin}/{plugin}.js'.format(plugin=plugin))
            for plugin in getattr(settings, 'REDACTOR_OPTIONS', {}).get('plugins', [])
        ]

        css = {
            "all": [
{'fraction_non_alphanumeric': 0.11947069943289225, 'fraction_numerical': 0.0, 'mean_word_length': 3.1933438985736924, 'pattern_counts': {'":': 2, '<': 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': '47754', 'n_tokens_mistral': 768, 'n_tokens_neox': 740, 'n_words': 177}