<commit_before>from django import forms
from django.utils import simplejson as json
from django.conf import settings

class JSONWidget(forms.Textarea):
    def render(self, name, value, attrs=None):
        if value is None:
            value = ""
        if not isinstance(value, basestring):
            value = json.dumps(value, indent=2)
        return super(JSONWidget, self).render(name, value, attrs)


class JSONSelectWidget(forms.SelectMultiple):
    pass

class JSONTableWidget(JSONWidget):
    class Media:
        js = (
            getattr(settings, 'STATIC_URL', settings.MEDIA_URL) + 'js/jquery-1.4.4.js',
            getattr(settings, 'STATIC_URL', settings.MEDIA_URL) + 'js/jquery.tmpl.js',
            getattr(settings, 'STATIC_URL', settings.MEDIA_URL) + 'js/form2object.js',
            getattr(settings, 'STATIC_URL', settings.MEDIA_URL) + 'js/json-table.js',
            getattr(settings, 'STATIC_URL', settings.MEDIA_URL) + 'js/json-table-templates.js',
        )<commit_msg>Fixed the JSONTableWidget so it works if MEDIA_URL is None<commit_after>from django import forms
from django.utils import simplejson as json
from django.conf import settings

class JSONWidget(forms.Textarea):
    def render(self, name, value, attrs=None):
        if value is None:
            value = ""
        if not isinstance(value, basestring):
            value = json.dumps(value, indent=2)
        return super(JSONWidget, self).render(name, value, attrs)


class JSONSelectWidget(forms.SelectMultiple):
    pass

class JSONTableWidget(JSONWidget):
    class Media:
        if (hasattr(settings, 'STATIC_URL') and settings.STATIC_URL) or settings.MEDIA_URL:
            js = (
                getattr(settings, 'STATIC_URL', settings.MEDIA_URL) + 'js/jquery-1.4.4.js',
                getattr(settings, 'STATIC_URL', settings.MEDIA_URL) + 'js/jquery.tmpl.js',
                getattr(settings, 'STATIC_URL', settings.MEDIA_URL) + 'js/form2object.js',
                getattr(settings, 'STATIC_URL', settings.MEDIA_URL) + 'js/json-table.js',
                getattr(settings, 'STATIC_URL', settings.MEDIA_URL) + 'js/json-table-templates.js',
            )
{'fraction_non_alphanumeric': 0.11661267931513189, 'fraction_numerical': 0.004627487274409995, 'mean_word_length': 2.9815837937384897, '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': '878042', 'n_tokens_mistral': 668, 'n_tokens_neox': 650, 'n_words': 148}