<commit_before># -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.conf.urls import url
from django.db.models import get_app, get_models

from . import utils
from .views import (
    CRUDCreateView,
    CRUDDeleteView,
    CRUDDetailView,
    CRUDListView,
    CRUDUpdateView,
)


def crud_for_model(model, urlprefix=None):
    """
    Returns list of ``url`` items to CRUD a model.
    """
    model_lower = model.__name__.lower()

    if urlprefix is None:
        urlprefix = ''
    urlprefix += model_lower

    urls = []

    urls.append(url(
        r'%s/new/$' % urlprefix,
        CRUDCreateView.as_view(model=model),
        name=utils.crud_url_name(model, utils.ACTION_CREATE)
    ))

    urls.append(url(
        r'%s/remove/(?P<pk>\d+)/$' % urlprefix,
        CRUDDeleteView.as_view(model=model),
        name=utils.crud_url_name(model, utils.ACTION_DELETE)
    ))

    urls.append(url(
        r'%s/(?P<pk>\d+)/$' % urlprefix,
        CRUDDetailView.as_view(model=model),
        name=utils.crud_url_name(model, utils.ACTION_DETAIL)
    ))

    urls.append(url(
        r'%s/edit/(?P<pk>\d+)/$' % urlprefix,
        CRUDUpdateView.as_view(model=model),
        name=utils.crud_url_name(model, utils.ACTION_UPDATE)
    ))

    urls.append(url(
        r'%s/$' % urlprefix,
        CRUDListView.as_view(model=model),
        name=utils.crud_url_name(model, utils.ACTION_LIST)
    ))

    return urls


def crud_for_app(app_label):
    """
    Returns list of ``url`` items to CRUD an app.
    """
    app = get_app(app_label)
    urls = []
    urlprefix = app_label + '/'
    for model in get_models(app):
        urls += crud_for_model(model, urlprefix)
    return urls<commit_msg>Add arg urlprefix in crud_for_app<commit_after># -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.conf.urls import url
from django.db.models import get_app, get_models

from . import utils
from .views import (
    CRUDCreateView,
    CRUDDeleteView,
    CRUDDetailView,
    CRUDListView,
    CRUDUpdateView,
)


def crud_for_model(model, urlprefix=None):
    """
    Returns list of ``url`` items to CRUD a model.
    """
    model_lower = model.__name__.lower()

    if urlprefix is None:
        urlprefix = ''
    urlprefix += model_lower

    urls = []

    urls.append(url(
        r'%s/new/$' % urlprefix,
        CRUDCreateView.as_view(model=model),
        name=utils.crud_url_name(model, utils.ACTION_CREATE)
    ))

    urls.append(url(
        r'%s/remove/(?P<pk>\d+)/$' % urlprefix,
        CRUDDeleteView.as_view(model=model),
        name=utils.crud_url_name(model, utils.ACTION_DELETE)
    ))

    urls.append(url(
        r'%s/(?P<pk>\d+)/$' % urlprefix,
        CRUDDetailView.as_view(model=model),
        name=utils.crud_url_name(model, utils.ACTION_DETAIL)
    ))

    urls.append(url(
        r'%s/edit/(?P<pk>\d+)/$' % urlprefix,
        CRUDUpdateView.as_view(model=model),
        name=utils.crud_url_name(model, utils.ACTION_UPDATE)
    ))

    urls.append(url(
        r'%s/$' % urlprefix,
        CRUDListView.as_view(model=model),
        name=utils.crud_url_name(model, utils.ACTION_LIST)
    ))

    return urls


def crud_for_app(app_label, urlprefix=None):
    """
    Returns list of ``url`` items to CRUD an app.
    """
    if urlprefix is None:
        urlprefix = app_label + '/'
    app = get_app(app_label)
    urls = []
    for model in get_models(app):
        urls += crud_for_model(model, urlprefix)
    return urls
{'fraction_non_alphanumeric': 0.1327812678469446, 'fraction_numerical': 0.0005711022272986865, 'mean_word_length': 2.726595744680851, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '709004', 'n_tokens_mistral': 1276, 'n_tokens_neox': 1261, 'n_words': 220}