<commit_before>import sys
import re

from django.core.urlresolvers import RegexURLPattern, RegexURLResolver
from django.core.management.base import BaseCommand
from django.utils import simplejson
from django.utils.datastructures import SortedDict
from django.conf import settings as project_settings
from django_js_utils import settings as app_settings

RE_KWARG = re.compile(r"(\(\?P\<(.*?)\>.*?\))") #Pattern for recongnizing named parameters in urls
RE_ARG = re.compile(r"(\(.*?\))") #Pattern for recognizing unnamed url parameters

URLS_JS_GENERATED_FILE = getattr(project_settings, 'URLS_JS_GENERATED_FILE', app_settings.URLS_JS_GENERATED_FILE)
URLS_JS_TO_EXPOSE = getattr(project_settings, 'URLS_JS_TO_EXPOSE', app_settings.URLS_JS_TO_EXPOSE)

class Command(BaseCommand):
    def handle(self, *args, **options):
        """
        Create urls.js file by parsing all of the urlpatterns in the root urls.py file
        """
        js_patterns = SortedDict()
        print "Generating Javascript urls file %s" % URLS_JS_GENERATED_FILE
        Command.handle_url_module(js_patterns, project_settings.ROOT_URLCONF)
        #output to the file
        urls_file = open(URLS_JS_GENERATED_FILE, "w")<commit_msg>Fix to allow it to work with named URL parameters like '^_a/_support/(?P<sessID>[a-zA-Z0-9]+)/_fields/(?P<interactionType>(pre|post))/$'  (before this fix it would produce a string like "/_a/_support/<sessID>/_fields/<interactionType>)/", instead of "/_a/_support/<sessID>/_fields/<interactionType>/"<commit_after>import sys
import re

from django.core.urlresolvers import RegexURLPattern, RegexURLResolver
from django.core.management.base import BaseCommand
from django.utils import simplejson
from django.utils.datastructures import SortedDict
from django.conf import settings as project_settings
from django_js_utils import settings as app_settings

RE_KWARG = re.compile(r"(\(\?P\<(.*?)\>.*?\)\)?)") #Pattern for recongnizing named parameters in urls
RE_ARG = re.compile(r"(\(.*?\))") #Pattern for recognizing unnamed url parameters

URLS_JS_GENERATED_FILE = getattr(project_settings, 'URLS_JS_GENERATED_FILE', app_settings.URLS_JS_GENERATED_FILE)
URLS_JS_TO_EXPOSE = getattr(project_settings, 'URLS_JS_TO_EXPOSE', app_settings.URLS_JS_TO_EXPOSE)

class Command(BaseCommand):
    def handle(self, *args, **options):
        """
        Create urls.js file by parsing all of the urlpatterns in the root urls.py file
        """
        js_patterns = SortedDict()
        print "Generating Javascript urls file %s" % URLS_JS_GENERATED_FILE
        Command.handle_url_module(js_patterns, project_settings.ROOT_URLCONF)
        #output to the file
        urls_file = open(URLS_JS_GENERATED_FILE, "w")
{'fraction_non_alphanumeric': 0.10250737463126844, 'fraction_numerical': 0.0007374631268436578, 'mean_word_length': 4.988962472406181, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '1451764', 'n_tokens_mistral': 885, 'n_tokens_neox': 870, 'n_words': 215}