<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# django-codenerix
#
# Copyright 2017 Centrologic Computational Logistic Center S.L.
#
# Project URL : http://www.codenerix.com
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from django import VERSION

DEBUG_TOOLBAR_DEFAULT_PANELS = (
    'debug_toolbar.panels.version.VersionDebugPanel',
    'debug_toolbar.panels.timer.TimerDebugPanel',
    'debug_toolbar.panels.settings.SettingsPanel',
    'debug_toolbar.panels.headers.HeaderDebugPanel',
    'debug_toolbar.panels.request_vars.RequestVarsDebugPanel',
    'debug_toolbar.panels.template.TemplateDebugPanel',
    'debug_toolbar.panels.sql.SQLDebugPanel',
    'debug_toolbar.panels.signals.SignalDebugPanel',
    'debug_toolbar.panels.logging.LoggingPanel',
)
DEBUG_TOOLBAR_DEFAULT_CONFIG = {
    'INTERCEPT_REDIRECTS': False,
}
# Autoload
def autoload(INSTALLED_APPS, MIDDLEWARE, DEBUG=False, SPAGHETTI=False, ROSETTA=False, ADMINSITE=False, DEBUG_TOOLBAR=False, DEBUG_PANEL=False, SNIPPET_SCREAM=False, GRAPH_MODELS=False, CODENERIX_DISABLE_LOG=False):
    EXTRA_MIDDLEWARES=[]
    if DEBUG and SPAGHETTI:
        INSTALLED_APPS += ('django_spaghetti',)
    if DEBUG and ROSETTA:
        INSTALLED_APPS+=('rosetta',)
    if 'django.contrib.admin' not in INSTALLED_APPS and not CODENERIX_DISABLE_LOG:
        INSTALLED_APPS+=('django.contrib.admin',)
    if DEBUG and ADMINSITE and not CODENERIX_DISABLE_LOG:
        EXTRA_MIDDLEWARES.append('django.contrib.messages.middleware.MessageMiddleware')
    if DEBUG and DEBUG_TOOLBAR:
        INSTALLED_APPS+=('debug_toolbar',)
        if DEBUG_PANEL:
            INSTALLED_APPS += ('debug_panel',)
            EXTRA_MIDDLEWARES.append('debug_panel.middleware.DebugPanelMiddleware')
        else:
            EXTRA_MIDDLEWARES.append('debug_toolbar.middleware.DebugToolbarMiddleware')
    if DEBUG and SNIPPET_SCREAM:
        EXTRA_MIDDLEWARES.append('snippetscream.ProfileMiddleware')
    if DEBUG and GRAPH_MODELS:
        INSTALLED_APPS += ('django_extensions',)

    # Attach new middlewares
    if type(MIDDLEWARE)==tuple:
        MIDDLEWARE+=tuple(EXTRA_MIDDLEWARES)
    else:
        MIDDLEWARE+=list(EXTRA_MIDDLEWARES)

    # Return final results
    return (INSTALLED_APPS, MIDDLEWARE)

# Autourl
def autourl(URLPATTERNS, DEBUG, ROSETTA, ADMINSITE, SPAGHETTI):
    from django.conf.urls import include, url
    if ROSETTA:
        URLPATTERNS += [url(r'^rosetta/', include('rosetta.urls'))]
    if VERSION[0] < 2 and ADMINSITE:
        from django.contrib import admin
        URLPATTERNS += [url(r'^admin', include(admin.site.urls))]
        URLPATTERNS += [url(r'^admin/', include(admin.site.urls))]
    if DEBUG and SPAGHETTI:
        URLPATTERNS += [url(r'^plate/', include('django_spaghetti.urls'))]
    return URLPATTERNS


# Codenerix STATIC
def codenerix_statics(DEBUG, STATIC_URL="/static/"):

    # Backward compatibility for older configurations (CODENERIXSOURCE is deprecated from now!)
    if type(STATIC_URL) is bool:
        DEBUG = STATIC_URL
        STATIC_URL = "/static/"

    locales = '\
    <script type="text/javascript" src="{STATIC_URL}codenerix/lib/bootstrap-datetimepicker/js/locales/bootstrap-datetimepicker.ar.js"></script> \
    <script type="text/javascript" src="{STATIC_URL}codenerix/lib/bootstrap-datetimepicker/js/locales/bootstrap-datetimepicker.bg.js"></script> \
    <script type="text/javascript" src="{STATIC_URL}codenerix/lib/bootstrap-datetimepicker/js/locales/bootstrap-datetimepicker.ca.js"></script> \
    <script type="text/javascript" src="{STATIC_URL}codenerix/lib/bootstrap-datetimepicker/js/locales/bootstrap-datetimepicker.cs.js"></script> \
    <script type="text/javascript" src="{STATIC_URL}codenerix/lib/bootstrap-datetimepicker/js/locales/bootstrap-datetimepicker.da.js"></script> \
    <script type="text/javascript" src="{STATIC_URL}codenerix/lib/bootstrap-datetimepicker/js/locales/bootstrap-datetimepicker.de.js"></script> \
    <script type="text/javascript" src="{STATIC_URL}codenerix/lib/bootstrap-datetimepicker/js/locales/bootstrap-datetimepicker.ee.js"></script> \
    <script type="text/javascript" src="{STATIC_URL}codenerix/lib/bootstrap-datetimepicker/js/locales/bootstrap-datetimepicker.el.js"></script> \
    <script type="text/javascript" src="{STATIC_URL}codenerix/lib/bootstrap-datetimepicker/js/locales/bootstrap-datetimepicker.es.js"></script> \
    <script type="text/javascript" src="{STATIC_URL}codenerix/lib/bootstrap-datetimepicker/js/locales/bootstrap-datetimepicker.fi.js"></script> \
    <script type="text/javascript" src="{STATIC_URL}codenerix/lib/bootstrap-datetimepicker/js/locales/bootstrap-datetimepicker.fr.js"></script> \
    <script type="text/javascript" src="{STATIC_URL}codenerix/lib/bootstrap-datetimepicker/js/locales/bootstrap-datetimepicker.he.js"></script> \
    <script type="text/javascript" src="{STATIC_URL}codenerix/lib/bootstrap-datetimepicker/js/locales/bootstrap-datetimepicker.hr.js"></script> \
    <script type="text/javascript" src="{STATIC_URL}codenerix/lib/bootstrap-datetimepicker/js/locales/bootstrap-datetimepicker.hu.js"></script> \
    <script type="text/javascript" src="{STATIC_URL}codenerix/lib/bootstrap-datetimepicker/js/locales/bootstrap-datetimepicker.id.js"></script> \<commit_msg>Added admim URLs for Django2<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# django-codenerix
#
# Copyright 2017 Centrologic Computational Logistic Center S.L.
#
# Project URL : http://www.codenerix.com
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from django import VERSION

DEBUG_TOOLBAR_DEFAULT_PANELS = (
    'debug_toolbar.panels.version.VersionDebugPanel',
    'debug_toolbar.panels.timer.TimerDebugPanel',
    'debug_toolbar.panels.settings.SettingsPanel',
    'debug_toolbar.panels.headers.HeaderDebugPanel',
    'debug_toolbar.panels.request_vars.RequestVarsDebugPanel',
    'debug_toolbar.panels.template.TemplateDebugPanel',
    'debug_toolbar.panels.sql.SQLDebugPanel',
    'debug_toolbar.panels.signals.SignalDebugPanel',
    'debug_toolbar.panels.logging.LoggingPanel',
)
DEBUG_TOOLBAR_DEFAULT_CONFIG = {
    'INTERCEPT_REDIRECTS': False,
}


# Autoload
def autoload(INSTALLED_APPS, MIDDLEWARE, DEBUG=False, SPAGHETTI=False, ROSETTA=False, ADMINSITE=False, DEBUG_TOOLBAR=False, DEBUG_PANEL=False, SNIPPET_SCREAM=False, GRAPH_MODELS=False, CODENERIX_DISABLE_LOG=False):
    EXTRA_MIDDLEWARES = []
    if DEBUG and SPAGHETTI:
        INSTALLED_APPS += ('django_spaghetti',)
    if DEBUG and ROSETTA:
        INSTALLED_APPS += ('rosetta',)
    if 'django.contrib.admin' not in INSTALLED_APPS and not CODENERIX_DISABLE_LOG:
        INSTALLED_APPS += ('django.contrib.admin',)
    if DEBUG and ADMINSITE and not CODENERIX_DISABLE_LOG:
        EXTRA_MIDDLEWARES.append('django.contrib.messages.middleware.MessageMiddleware')
    if DEBUG and DEBUG_TOOLBAR:
        INSTALLED_APPS += ('debug_toolbar',)
        if DEBUG_PANEL:
            INSTALLED_APPS += ('debug_panel',)
            EXTRA_MIDDLEWARES.append('debug_panel.middleware.DebugPanelMiddleware')
        else:
            EXTRA_MIDDLEWARES.append('debug_toolbar.middleware.DebugToolbarMiddleware')
    if DEBUG and SNIPPET_SCREAM:
        EXTRA_MIDDLEWARES.append('snippetscream.ProfileMiddleware')
    if DEBUG and GRAPH_MODELS:
        INSTALLED_APPS += ('django_extensions',)

    # Attach new middlewares
    if type(MIDDLEWARE) == tuple:
        MIDDLEWARE += tuple(EXTRA_MIDDLEWARES)
    else:
        MIDDLEWARE += list(EXTRA_MIDDLEWARES)

    # Return final results
    return (INSTALLED_APPS, MIDDLEWARE)


# Autourl
def autourl(URLPATTERNS, DEBUG, ROSETTA, ADMINSITE, SPAGHETTI):
    from django.conf.urls import include, url

    if ROSETTA:
        URLPATTERNS += [url(r'^rosetta/', include('rosetta.urls'))]

    if ADMINSITE:
        from django.contrib import admin
        if VERSION[0] < 2 and ADMINSITE:
            URLPATTERNS += [url(r'^admin', include(admin.site.urls))]
            URLPATTERNS += [url(r'^admin/', include(admin.site.urls))]
        else:
            from django.urls import path
            URLPATTERNS += [path('admin', admin.site.urls, )]
            URLPATTERNS += [path('admin/', admin.site.urls, )]
    if DEBUG and SPAGHETTI:
        URLPATTERNS += [url(r'^plate/', include('django_spaghetti.urls'))]
    return URLPATTERNS


# Codenerix STATIC
def codenerix_statics(DEBUG, STATIC_URL="/static/"):

    # Backward compatibility for older configurations (CODENERIXSOURCE is deprecated from now!)
    if type(STATIC_URL) is bool:
        DEBUG = STATIC_URL
        STATIC_URL = "/static/"

    locales = '\
    <script type="text/javascript" src="{STATIC_URL}codenerix/lib/bootstrap-datetimepicker/js/locales/bootstrap-datetimepicker.ar.js"></script> \
    <script type="text/javascript" src="{STATIC_URL}codenerix/lib/bootstrap-datetimepicker/js/locales/bootstrap-datetimepicker.bg.js"></script> \
    <script type="text/javascript" src="{STATIC_URL}codenerix/lib/bootstrap-datetimepicker/js/locales/bootstrap-datetimepicker.ca.js"></script> \
    <script type="text/javascript" src="{STATIC_URL}codenerix/lib/bootstrap-datetimepicker/js/locales/bootstrap-datetimepicker.cs.js"></script> \
    <script type="text/javascript" src="{STATIC_URL}codenerix/lib/bootstrap-datetimepicker/js/locales/bootstrap-datetimepicker.da.js"></script> \
    <script type="text/javascript" src="{STATIC_URL}codenerix/lib/bootstrap-datetimepicker/js/locales/bootstrap-datetimepicker.de.js"></script> \
    <script type="text/javascript" src="{STATIC_URL}codenerix/lib/bootstrap-datetimepicker/js/locales/bootstrap-datetimepicker.ee.js"></script> \
    <script type="text/javascript" src="{STATIC_URL}codenerix/lib/bootstrap-datetimepicker/js/locales/bootstrap-datetimepicker.el.js"></script> \
    <script type="text/javascript" src="{STATIC_URL}codenerix/lib/bootstrap-datetimepicker/js/locales/bootstrap-datetimepicker.es.js"></script> \
    <script type="text/javascript" src="{STATIC_URL}codenerix/lib/bootstrap-datetimepicker/js/locales/bootstrap-datetimepicker.fi.js"></script> \
    <script type="text/javascript" src="{STATIC_URL}codenerix/lib/bootstrap-datetimepicker/js/locales/bootstrap-datetimepicker.fr.js"></script> \
    <script type="text/javascript" src="{STATIC_URL}codenerix/lib/bootstrap-datetimepicker/js/locales/bootstrap-datetimepicker.he.js"></script> \
    <script type="text/javascript" src="{STATIC_URL}codenerix/lib/bootstrap-datetimepicker/js/locales/bootstrap-datetimepicker.hr.js"></script> \
    <script type="text/javascript" src="{STATIC_URL}codenerix/lib/bootstrap-datetimepicker/js/locales/bootstrap-datetimepicker.hu.js"></script> \
    <script type="text/javascript" src="{STATIC_URL}codenerix/lib/bootstrap-datetimepicker/js/locales/bootstrap-datetimepicker.id.js"></script> \
{'fraction_non_alphanumeric': 0.1257840311917274, 'fraction_numerical': 0.0019494829632141042, 'mean_word_length': 4.599905078310394, 'pattern_counts': {'":': 0, '<': 65, '<?xml version=': 0, '>': 63, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, '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': '2802661', 'n_tokens_mistral': 3905, 'n_tokens_neox': 3786, 'n_words': 621}