text
stringlengths
0
1.05M
meta
dict
from functools import wraps from django.http import Http404 from django.contrib.auth.models import User from repository.models import Repository from git.repo import Repo def require_existing_repo(func): """ Checks to see if requested repository is available on user's deposit. Raises 404 if ...
{ "repo_name": "Djacket/djacket", "path": "core/backend/repository/decorators.py", "copies": "1", "size": "2902", "license": "mit", "hash": 3152629704294879000, "line_mean": 28.9175257732, "line_max": 95, "alpha_frac": 0.5920055134, "autogenerated": false, "ratio": 4.403641881638847, "config_tes...
from functools import wraps from django.http import Http404 from django.shortcuts import redirect, reverse from applications.models import Event, Period, EventApplication from userprofile.models import User def study_group_application(func): @wraps(func) def decorated(req, **kwargs): try: ...
{ "repo_name": "CSchool/SchoolSite", "path": "CSchoolSite/applications/decorators.py", "copies": "1", "size": "1220", "license": "apache-2.0", "hash": 5019149937220498000, "line_mean": 33.8857142857, "line_max": 111, "alpha_frac": 0.5745901639, "autogenerated": false, "ratio": 4.552238805970149, ...
from functools import wraps from django.http import Http404 from django.utils.decorators import available_attrs from django.core.urlresolvers import reverse, NoReverseMatch from django.shortcuts import redirect from waffle import flag_is_active, switch_is_active def waffle_flag(flag_name, redirect_to=None): def...
{ "repo_name": "crccheck/django-waffle", "path": "waffle/decorators.py", "copies": "1", "size": "1867", "license": "bsd-3-clause", "hash": -6211141240905511000, "line_mean": 31.1896551724, "line_max": 79, "alpha_frac": 0.5977504017, "autogenerated": false, "ratio": 4.282110091743119, "config_tes...
from functools import wraps from django.http import Http404 from django.utils.decorators import available_attrs from waffle import flag_is_active, switch_is_active def waffle_flag(flag_name): def decorator(view): @wraps(view, assigned=available_attrs(view)) def _wrapped_view(request, *args, **kw...
{ "repo_name": "ilanbm/django-waffle", "path": "waffle/decorators.py", "copies": "2", "size": "1194", "license": "bsd-3-clause", "hash": 6143908819002699000, "line_mean": 30.4210526316, "line_max": 71, "alpha_frac": 0.594639866, "autogenerated": false, "ratio": 4.131487889273356, "config_test": ...
from functools import wraps from django.http import HttpRequest from django.middleware.cache import CacheMiddleware from django.utils.cache import add_never_cache_headers, patch_cache_control from django.utils.decorators import decorator_from_middleware_with_args def cache_page(timeout, *, cache=None, key_prefix=Non...
{ "repo_name": "freakboy3742/django", "path": "django/views/decorators/cache.py", "copies": "15", "size": "2272", "license": "bsd-3-clause", "hash": -1093650366277413000, "line_mean": 37.5084745763, "line_max": 78, "alpha_frac": 0.6593309859, "autogenerated": false, "ratio": 4.42023346303502, "c...
from functools import wraps from django.http import HttpResponseForbidden from django.core.exceptions import ImproperlyConfigured from .endpoints import Server from .oauth2_validators import OAuth2Validator from .oauth2_backends import OAuthLibCore from .settings import oauth2_settings def protected_resource(scopes...
{ "repo_name": "vmalavolta/django-oauth-toolkit", "path": "oauth2_provider/decorators.py", "copies": "1", "size": "3060", "license": "bsd-2-clause", "hash": -835289865141208300, "line_mean": 35.4285714286, "line_max": 98, "alpha_frac": 0.6160130719, "autogenerated": false, "ratio": 4.5535714285714...
from functools import wraps from django.http import HttpResponseForbidden from ratelimit.backends.cachebe import CacheBackend def _method_match(request, method=None): if method is None: method = ['GET', 'POST', 'PUT', 'DELETE', 'HEAD'] if not isinstance(method, list): method = [method] r...
{ "repo_name": "haoqili/MozSecWorld", "path": "vendor-local/packages/django-ratelimit/ratelimit/decorators.py", "copies": "1", "size": "1178", "license": "bsd-3-clause", "hash": 6072709293204948000, "line_mean": 24.6086956522, "line_max": 73, "alpha_frac": 0.5772495756, "autogenerated": false, "ra...
from functools import wraps from django.http import HttpResponse, HttpResponseRedirect, HttpResponseBadRequest from django.shortcuts import render_to_response from django.template import RequestContext from django.core.urlresolvers import reverse, resolve from django.views.decorators.csrf import csrf_exempt from atla...
{ "repo_name": "praekelt/django-atlas", "path": "atlas/views.py", "copies": "1", "size": "2949", "license": "bsd-3-clause", "hash": 1577780980751388200, "line_mean": 38.8513513514, "line_max": 108, "alpha_frac": 0.6358087487, "autogenerated": false, "ratio": 4.6078125, "config_test": false, "h...
from functools import wraps from django.http import HttpResponse from django.core.exceptions import ValidationError import django.views.decorators.csrf import yaml from django.conf import settings from canvas import url_util from canvas.util import ArgSpec, simple_decorator, loads, client_dumps, JSONDecodeError from ...
{ "repo_name": "canvasnetworks/canvas", "path": "website/canvas/api_decorators.py", "copies": "1", "size": "7487", "license": "bsd-3-clause", "hash": -7852641585767367000, "line_mean": 40.5944444444, "line_max": 122, "alpha_frac": 0.6415119541, "autogenerated": false, "ratio": 4.251561612720045, ...
from functools import wraps from django.http import HttpResponse from django.core.urlresolvers import reverse from django.core.handlers.wsgi import WSGIRequest from fandjango.utils import get_post_authorization_redirect_url from fandjango.views import authorize_application from fandjango.settings import FACEBOOK_APPL...
{ "repo_name": "jgorset/fandjango", "path": "fandjango/decorators.py", "copies": "1", "size": "3107", "license": "mit", "hash": 4698214394024866000, "line_mean": 46.8, "line_max": 115, "alpha_frac": 0.663984551, "autogenerated": false, "ratio": 5.003220611916264, "config_test": false, "has_no_...
from functools import wraps from django.http import HttpResponse from django.shortcuts import render_to_response from django.utils import simplejson from django.template import RequestContext def render_to(template=None): def renderer(function): @wraps(function) def wrapper(request, *args, **kwar...
{ "repo_name": "dbreen/mazerunjs", "path": "mazerun/utils/decorators.py", "copies": "1", "size": "1093", "license": "mit", "hash": -798625285044599300, "line_mean": 30.2285714286, "line_max": 103, "alpha_frac": 0.6605672461, "autogenerated": false, "ratio": 4.573221757322176, "config_test": fals...
from functools import wraps from django.http import HttpResponse from django.template.loader import render_to_string, get_template from django.template import RequestContext from slimmer import slimmer from paucore.utils.data import is_seq_not_string from paucore.stats.statsd_client import graphite_timer def minify...
{ "repo_name": "appdotnet/alpha", "path": "paucore/web/template.py", "copies": "3", "size": "3387", "license": "mit", "hash": -3479823916990917600, "line_mean": 31.2571428571, "line_max": 120, "alpha_frac": 0.6111603189, "autogenerated": false, "ratio": 3.902073732718894, "config_test": false, ...
from functools import wraps from django.http import HttpResponse def _action_renderer(renderer, **renderer_kwargs): def decorator(function): @wraps(function) def _wrapped_action(self, *args, **kwargs): """Wrapper for the function called by the url.""" response = function(s...
{ "repo_name": "zeraien/django-url-framework", "path": "django_url_framework/decorators/render.py", "copies": "1", "size": "1816", "license": "mit", "hash": -4807058447792839000, "line_mean": 41.2325581395, "line_max": 128, "alpha_frac": 0.7004405286, "autogenerated": false, "ratio": 4.49504950495...
from functools import wraps from django.http import HttpResponseRedirect from .utils import get_dropbox_auth_flow from .views import DROPBOX_ACCESS_TOKEN def require_dropbox_session(next_url=None): """ Any view that is wrapped with this will redirect to the dropbox authorization site if the user does not ...
{ "repo_name": "qedsoftware/commcare-hq", "path": "corehq/apps/dropbox/decorators.py", "copies": "2", "size": "1200", "license": "bsd-3-clause", "hash": -5184034912629061000, "line_mean": 36.5, "line_max": 108, "alpha_frac": 0.6216666667, "autogenerated": false, "ratio": 4.363636363636363, "conf...
from functools import wraps from django.http import * from django.shortcuts import render_to_response from django.template.context import RequestContext from merlin.wizards import MissingStepException, MissingSlugException from merlin.wizards.utils import * def modifies_session(func): @wraps(func) def wrapp...
{ "repo_name": "supercodepoet/django-merlin", "path": "src/merlin/wizards/session.py", "copies": "1", "size": "15866", "license": "bsd-3-clause", "hash": 4313827826305920500, "line_mean": 31.7809917355, "line_max": 81, "alpha_frac": 0.5914534224, "autogenerated": false, "ratio": 4.5855491329479765...
from functools import wraps from django.http.response import HttpResponse from atlassian_jwt_auth.frameworks.django.decorators import with_asap def validate_asap(issuers=None, subjects=None, required=True): """Decorator to allow endpoint-specific ASAP authorization, assuming ASAP authentication has already ...
{ "repo_name": "atlassian/asap-authentication-python", "path": "atlassian_jwt_auth/contrib/django/decorators.py", "copies": "1", "size": "2125", "license": "mit", "hash": 689121540848075000, "line_mean": 38.3518518519, "line_max": 79, "alpha_frac": 0.6310588235, "autogenerated": false, "ratio": 4....
from functools import wraps from django import http from django.conf import settings from django.http import Http404 from amo.urlresolvers import reverse def locale_switcher(f): """Decorator redirecting clicks on the locale switcher dropdown.""" @wraps(f) def decorated(request, *args, **kwargs): ...
{ "repo_name": "beni55/olympia", "path": "apps/localizers/decorators.py", "copies": "21", "size": "1065", "license": "bsd-3-clause", "hash": 6118670073586490000, "line_mean": 32.28125, "line_max": 78, "alpha_frac": 0.6535211268, "autogenerated": false, "ratio": 4.143968871595331, "config_test": ...
from functools import wraps #from django import http from django.utils import simplejson from django.conf import settings from django.http import HttpResponseRedirect, HttpResponse from django.contrib.auth.decorators import login_required from django.utils.decorators import available_attrs def verify_required(view_f...
{ "repo_name": "shawiz/idlebook", "path": "idlebook/account/decorators.py", "copies": "1", "size": "2226", "license": "mit", "hash": -5298969003886104000, "line_mean": 38.0526315789, "line_max": 104, "alpha_frac": 0.641509434, "autogenerated": false, "ratio": 4.192090395480226, "config_test": fa...
from functools import wraps from django.middleware.cache import CacheMiddleware from django.utils.cache import add_never_cache_headers, patch_cache_control from django.utils.decorators import decorator_from_middleware_with_args def cache_page(*args, **kwargs): """ Decorator for views that tries getting the p...
{ "repo_name": "twz915/django", "path": "django/views/decorators/cache.py", "copies": "2", "size": "2205", "license": "bsd-3-clause", "hash": 7355844347681191000, "line_mean": 37.0172413793, "line_max": 94, "alpha_frac": 0.6947845805, "autogenerated": false, "ratio": 4.144736842105263, "config_t...
from functools import wraps from django.middleware.cache import CacheMiddleware from django.utils.cache import add_never_cache_headers, patch_cache_control from django.utils.decorators import ( available_attrs, decorator_from_middleware_with_args, ) def cache_page(*args, **kwargs): """ Decorator for view...
{ "repo_name": "craynot/django", "path": "django/views/decorators/cache.py", "copies": "586", "size": "2304", "license": "bsd-3-clause", "hash": -6313222406767750000, "line_mean": 37.4, "line_max": 94, "alpha_frac": 0.6970486111, "autogenerated": false, "ratio": 4.114285714285714, "config_test":...
from functools import wraps from django.middleware.csrf import CsrfViewMiddleware, get_token from django.utils.decorators import available_attrs, decorator_from_middleware csrf_protect = decorator_from_middleware(CsrfViewMiddleware) csrf_protect.__name__ = "csrf_protect" csrf_protect.__doc__ = """ This decorator adds...
{ "repo_name": "zhoulingjun/django", "path": "django/views/decorators/csrf.py", "copies": "586", "size": "2202", "license": "bsd-3-clause", "hash": 4937777100078680000, "line_mean": 35.7, "line_max": 111, "alpha_frac": 0.7325158946, "autogenerated": false, "ratio": 3.960431654676259, "config_tes...
from functools import wraps from django.middleware.csrf import CsrfViewMiddleware, get_token from django.utils.decorators import decorator_from_middleware csrf_protect = decorator_from_middleware(CsrfViewMiddleware) csrf_protect.__name__ = "csrf_protect" csrf_protect.__doc__ = """ This decorator adds CSRF protection ...
{ "repo_name": "Beauhurst/django", "path": "django/views/decorators/csrf.py", "copies": "124", "size": "2073", "license": "bsd-3-clause", "hash": 445920326283582900, "line_mean": 36.0178571429, "line_max": 88, "alpha_frac": 0.7366136035, "autogenerated": false, "ratio": 4.009671179883946, "confi...
from functools import wraps from django.shortcuts import get_object_or_404 from django.utils import timezone from rest_framework import status from rest_framework.views import APIView from rest_framework.response import Response from core.models.machine_request import MachineRequest as CoreMachineRequest from core.m...
{ "repo_name": "CCI-MOC/GUI-Backend", "path": "api/v1/views/cloud_admin.py", "copies": "1", "size": "11208", "license": "apache-2.0", "hash": 661885502406507300, "line_mean": 36.2358803987, "line_max": 79, "alpha_frac": 0.6302640971, "autogenerated": false, "ratio": 4.7271193589202865, "config_t...
from functools import wraps from django.shortcuts import redirect from django.conf import settings from django.http import JsonResponse from django.utils.translation import ugettext as _ from django.contrib import messages from .models import GameControl def registration_open_required(view): """ View decora...
{ "repo_name": "fausecteam/ctf-gameserver", "path": "src/ctf_gameserver/web/scoring/decorators.py", "copies": "1", "size": "2671", "license": "isc", "hash": -905953403768192400, "line_mean": 29.3522727273, "line_max": 107, "alpha_frac": 0.6548109322, "autogenerated": false, "ratio": 4.511824324324...
from functools import wraps from django.shortcuts import redirect from django.contrib.auth import get_user_model from .models import Blog def create_or_edit_blog(view_func): """ The sole purpose of this decorator is to redirect bloggers/readers to appropriate view depending upon their origin of request....
{ "repo_name": "v1k45/blogghar", "path": "blog/decorators.py", "copies": "1", "size": "2846", "license": "mit", "hash": 7214531260371839000, "line_mean": 35.4871794872, "line_max": 79, "alpha_frac": 0.5906535488, "autogenerated": false, "ratio": 4.2990936555891235, "config_test": false, "has_n...
from functools import wraps from django.shortcuts import redirect from django.template.response import TemplateResponse from ...discount.forms import CheckoutDiscountForm def add_voucher_form(view): @wraps(view) def func(request, checkout): prefix = 'discount' data = {k: v for k, v in reques...
{ "repo_name": "laosunhust/saleor", "path": "saleor/checkout/views/discount.py", "copies": "4", "size": "1511", "license": "bsd-3-clause", "hash": 327912338459951600, "line_mean": 34.9761904762, "line_max": 78, "alpha_frac": 0.6201191264, "autogenerated": false, "ratio": 4.457227138643068, "conf...
from functools import wraps from django.shortcuts import render from django.http import HttpResponse from django.http.response import HttpResponseBase import weasyprint def pdf_response(template_name): """Returns either an HTML or PDF representation of the data that decorated function generates. Decision on...
{ "repo_name": "dchaplinsky/pep.org.ua", "path": "pepdb/core/pdf.py", "copies": "1", "size": "1568", "license": "mit", "hash": -133460144495013970, "line_mean": 34.6363636364, "line_max": 79, "alpha_frac": 0.5797193878, "autogenerated": false, "ratio": 4.930817610062893, "config_test": false, ...
from functools import wraps from django.shortcuts import render from django.shortcuts import render_to_response from django.views.generic.base import View from django.shortcuts import HttpResponseRedirect from models import * from forms import * # Create your views here. def check_login(func): @wraps(func) ...
{ "repo_name": "xsank/aijianli", "path": "matrix/views.py", "copies": "1", "size": "3341", "license": "mit", "hash": -6948940851726694000, "line_mean": 23.7481481481, "line_max": 78, "alpha_frac": 0.6040107752, "autogenerated": false, "ratio": 4.059538274605103, "config_test": false, "has_no_k...
from functools import wraps from django.shortcuts import render def render_to(template=None, content_type=None): """ Decorator for Django views that sends returned dict to render_to_response function. Template name can be decorator parameter or TEMPLATE item in returned dictionary. If view d...
{ "repo_name": "michaelmior/pylinks", "path": "pylinks/main/decorators.py", "copies": "1", "size": "1796", "license": "mit", "hash": -4070738289071998000, "line_mean": 28.4426229508, "line_max": 77, "alpha_frac": 0.609688196, "autogenerated": false, "ratio": 4.616966580976864, "config_test": fal...
from functools import wraps from django.shortcuts import render_to_response from django.http import HttpResponse def render_to(template=None, mobile_template=None, mimetype=None): """ Based upon django-annoying: https://bitbucket.org/offline/django-annoying/ Decorator for Django views that sends returned...
{ "repo_name": "jamespacileo/django-smartagent", "path": "smartagent/decorators.py", "copies": "1", "size": "1382", "license": "mit", "hash": 1948195469947212300, "line_mean": 39.6764705882, "line_max": 111, "alpha_frac": 0.6808972504, "autogenerated": false, "ratio": 4.866197183098592, "config_...
from functools import wraps from django.shortcuts import render_to_response from django.template import RequestContext from django.conf import settings from django.template import Context, Template from django.utils.encoding import smart_unicode from django import http from django.template.context import get_standard_...
{ "repo_name": "strogo/turbion", "path": "turbion/bits/utils/decorators.py", "copies": "1", "size": "4135", "license": "bsd-3-clause", "hash": 3978545124414290000, "line_mean": 31.0542635659, "line_max": 71, "alpha_frac": 0.5888754534, "autogenerated": false, "ratio": 4.413020277481324, "config_...
from functools import wraps from django.template.loader import render_to_string from django.core.mail import send_mail as django_send_mail from django.conf import settings from django.contrib.auth import get_user_model from django.db.models import Q from django.shortcuts import redirect from django.utils.translation i...
{ "repo_name": "serzans/wagtail", "path": "wagtail/wagtailadmin/utils.py", "copies": "1", "size": "6366", "license": "bsd-3-clause", "hash": -421064001848345200, "line_mean": 35.3771428571, "line_max": 107, "alpha_frac": 0.6564561734, "autogenerated": false, "ratio": 4.402489626556017, "config_t...
from functools import wraps from django.test import SimpleTestCase from django.test.utils import override_settings from .. import config __all__ = ('override_config',) class override_config(override_settings): """ Decorator to modify constance setting for TestCase. Based on django.test.utils.override_...
{ "repo_name": "jazzband/django-constance", "path": "constance/test/unittest.py", "copies": "1", "size": "2533", "license": "bsd-3-clause", "hash": -6346062528089096000, "line_mean": 28.8, "line_max": 78, "alpha_frac": 0.5906040268, "autogenerated": false, "ratio": 4.588768115942029, "config_tes...
from functools import wraps from django.test import TestCase from django.test.utils import override_settings from django.core.urlresolvers import reverse from profiles.models import AgdaUser from mdr.models import MDRScanJob fake_slug = 'asdfasdfasdfasdfasdf' def with_two_jobs(orig): @wraps(orig) def wrap...
{ "repo_name": "BILS/agda", "path": "agda/jobs/test_views.py", "copies": "1", "size": "10813", "license": "mit", "hash": 1680457305987761200, "line_mean": 37.4804270463, "line_max": 97, "alpha_frac": 0.6492185332, "autogenerated": false, "ratio": 3.654275092936803, "config_test": true, "has_no...
from functools import wraps from django.urls import reverse def get_urlname(obj): app_label, model_name = obj._meta.app_label, obj._meta.model_name return u'admin:{}_{}_change'.format(app_label, model_name) def link_list(urlname=None, short_description=None): """ Decorates a modeladmin method to di...
{ "repo_name": "Clarity-89/clarityv2", "path": "src/clarityv2/utils/admin/decorators.py", "copies": "1", "size": "1418", "license": "mit", "hash": 4271953238066841000, "line_mean": 31.976744186, "line_max": 98, "alpha_frac": 0.6057827927, "autogenerated": false, "ratio": 4.220238095238095, "conf...
from functools import wraps from django.utils.decorators import available_attrs from django.template.loader import render_to_string from django.template.response import RequestContext, SimpleTemplateResponse class BasicWidget(object): render_template = 'filters/widget.html' def __init__(self, extra={}, temp...
{ "repo_name": "ProstoKSI/django-filters", "path": "filters/widgets.py", "copies": "1", "size": "5199", "license": "mit", "hash": -6724157195555631000, "line_mean": 32.3269230769, "line_max": 121, "alpha_frac": 0.662819773, "autogenerated": false, "ratio": 4.080847723704866, "config_test": false...
from functools import wraps from django.utils.decorators import available_attrs from django.template.response import SimpleTemplateResponse from filters.widgets import generate_modifiers def modify_queryset(conf, var_name='list'): """ Example of usage: @to_template('template.html') @modif...
{ "repo_name": "ProstoKSI/django-filters", "path": "filters/decorators.py", "copies": "1", "size": "2201", "license": "mit", "hash": 8780411374258164000, "line_mean": 35.0819672131, "line_max": 98, "alpha_frac": 0.5197637438, "autogenerated": false, "ratio": 4.556935817805383, "config_test": fal...
from functools import wraps from django.utils.decorators import available_attrs from cacheback.function import FunctionJob def cacheback(lifetime=None, fetch_on_miss=None, job_class=None, task_options=None, **job_class_kwargs): """ Decorate function to cache its return value. :lifetime: H...
{ "repo_name": "jayfk/django-cacheback", "path": "cacheback/decorators.py", "copies": "5", "size": "1455", "license": "mit", "hash": 7580465361136172000, "line_mean": 37.2894736842, "line_max": 79, "alpha_frac": 0.6487972509, "autogenerated": false, "ratio": 4.24198250728863, "config_test": fals...
from functools import wraps from django.utils.decorators import available_attrs from .jobs import FunctionJob def cacheback(lifetime=None, fetch_on_miss=None, cache_alias=None, job_class=None, task_options=None, **job_class_kwargs): """ Decorate function to cache its return value. :lifeti...
{ "repo_name": "mitchelljkotler/django-cacheback", "path": "cacheback/decorators.py", "copies": "1", "size": "1572", "license": "mit", "hash": 8640025893309128000, "line_mean": 38.3, "line_max": 79, "alpha_frac": 0.6450381679, "autogenerated": false, "ratio": 4.225806451612903, "config_test": fa...
from functools import wraps from django.utils.decorators import available_attrs from rtime.utils import add_frame_data def request_wrapper(meth): @wraps(meth, assigned=available_attrs(meth)) def process_request(request): res = meth(request) if res is not None: m_class = meth.__se...
{ "repo_name": "amitu/rtime", "path": "src/djrtime/djrtime/wrappers.py", "copies": "1", "size": "2539", "license": "bsd-3-clause", "hash": 5993170580413778000, "line_mean": 31.1392405063, "line_max": 72, "alpha_frac": 0.5750295392, "autogenerated": false, "ratio": 4.155482815057283, "config_test...
from functools import wraps from django.utils.decorators import available_attrs from .toolbox import auth_handler_response def oauth_required(scope: str = None, scope_auto: bool = False): """Views decorator checking user oauth token. :param scope: scope identifier string to check token has access to the sc...
{ "repo_name": "idlesign/django-oauthost", "path": "oauthost/decorators.py", "copies": "1", "size": "1176", "license": "bsd-3-clause", "hash": -7751082107735652000, "line_mean": 35.75, "line_max": 112, "alpha_frac": 0.6445578231, "autogenerated": false, "ratio": 4.21505376344086, "config_test": ...
from functools import wraps from django.utils.decorators import available_attrs def header(name, value): # View decorator that sets a response header. # # Example: # @header('X-Powered-By', 'Django') # def view(request, ...): # .... # # For class-based views use: # @method_de...
{ "repo_name": "alexhayes/django-toolkit", "path": "django_toolkit/view_decorators.py", "copies": "1", "size": "1551", "license": "mit", "hash": -2935130970452081000, "line_mean": 28.2830188679, "line_max": 75, "alpha_frac": 0.5667311412, "autogenerated": false, "ratio": 3.946564885496183, "conf...
from functools import wraps from django.utils.decorators import available_attrs def xframe_options_deny(view_func): """ Modifies a view function so its response has the X-Frame-Options HTTP header set to 'DENY' as long as the response doesn't already have that header set. e.g. @xframe_optio...
{ "repo_name": "jnovinger/django", "path": "django/views/decorators/clickjacking.py", "copies": "145", "size": "1747", "license": "bsd-3-clause", "hash": -339757166711882900, "line_mean": 26.296875, "line_max": 78, "alpha_frac": 0.6433886663, "autogenerated": false, "ratio": 3.740899357601713, "...
from functools import wraps from django.utils.decorators import available_attrs def xframe_sameorigin(view_fn): @wraps(view_fn, assigned=available_attrs(view_fn)) def _wrapped_view(request, *args, **kwargs): response = view_fn(request, *args, **kwargs) response['X-Frame-Options'] = 'SAMEORIGI...
{ "repo_name": "mozilla/captain", "path": "vendor/lib/python/commonware/response/decorators.py", "copies": "1", "size": "1556", "license": "mpl-2.0", "hash": 3051555463055548400, "line_mean": 30.12, "line_max": 58, "alpha_frac": 0.6420308483, "autogenerated": false, "ratio": 3.5688073394495414, ...
from functools import wraps from django.utils.six.moves.urllib import parse from django.contrib.auth import REDIRECT_FIELD_NAME from django.contrib.auth.decorators import user_passes_test from django.shortcuts import render from django.contrib import messages from django.contrib.auth.views import redirect_to_login fro...
{ "repo_name": "lyoniionly/django-cobra", "path": "src/cobra/views/decorators.py", "copies": "1", "size": "4997", "license": "apache-2.0", "hash": -6817898100129555000, "line_mean": 38.6587301587, "line_max": 79, "alpha_frac": 0.6704022413, "autogenerated": false, "ratio": 4.3189282627484875, "c...
from functools import wraps from django.utils.translation import ugettext from .constants import SOURCE_MAP from .formatter import Format from .util import country_code_map, specific_location_timeframe from accounts.models import Network from pinecast.helpers import get_object_or_404, json_response def requires_net...
{ "repo_name": "AlmostBetterNetwork/pinecast", "path": "analytics/views_network.py", "copies": "3", "size": "5288", "license": "apache-2.0", "hash": -8920225955085831000, "line_mean": 31.6419753086, "line_max": 95, "alpha_frac": 0.5898260212, "autogenerated": false, "ratio": 3.4427083333333335, ...
from functools import wraps from django.utils.translation import ugettext import accounts.payment_plans as plans from .constants import SOURCE_MAP from .formatter import Format from .util import country_code_map, restrict, specific_location_timeframe from pinecast.helpers import get_object_or_404 from podcasts.models...
{ "repo_name": "AlmostBetterNetwork/podmaster-host", "path": "analytics/views_episode.py", "copies": "3", "size": "3009", "license": "apache-2.0", "hash": 1894689289248177700, "line_mean": 28.7920792079, "line_max": 86, "alpha_frac": 0.6321036889, "autogenerated": false, "ratio": 3.350779510022271...
from functools import wraps from django.views.decorators.cache import cache_page as django_cache_page import memcache import simplejson from canvas import util from configuration import Config from django.conf import settings cache = memcache.Client(settings.MEMCACHE_HOSTS) class DoesNotExist(object): pass clas...
{ "repo_name": "drawquest/drawquest-web", "path": "website/canvas/cache_patterns.py", "copies": "1", "size": "7757", "license": "bsd-3-clause", "hash": 2160291420709356500, "line_mean": 31.3208333333, "line_max": 162, "alpha_frac": 0.5962356581, "autogenerated": false, "ratio": 3.9355657026889905,...
from functools import wraps from elasticsearch_dsl.response import Response from elasticsearch_dsl.utils import AttrDict, AttrList, ObjectBase from django.http import JsonResponse from django.http.response import HttpResponseBase from django.shortcuts import render from .translator import Translator, NoOpTranslator ...
{ "repo_name": "dchaplinsky/declarations.com.ua", "path": "declarations_site/catalog/api.py", "copies": "1", "size": "3382", "license": "mit", "hash": -1329382229409496000, "line_mean": 38.7882352941, "line_max": 87, "alpha_frac": 0.6363098758, "autogenerated": false, "ratio": 4.341463414634147, ...
from functools import wraps from elasticsearch_dsl.result import Response from elasticsearch_dsl.utils import AttrDict, AttrList, ObjectBase from django.http import JsonResponse from django.shortcuts import render def serialize_for_api(data): """Transform complex types that we use into simple ones recursively. ...
{ "repo_name": "devrand/declarations.com.ua", "path": "declarations_site/catalog/api.py", "copies": "1", "size": "2021", "license": "mit", "hash": -4038673898076230000, "line_mean": 37.8653846154, "line_max": 79, "alpha_frac": 0.6813458684, "autogenerated": false, "ratio": 4.2280334728033475, "c...
from functools import wraps from elasticsearch import Elasticsearch _monkeypatched_es = False def monkeypatch_es(): """Monkey patch for elasticsearch-py 1.0+ to make it work with ES 0.90 1. tweaks elasticsearch.client.bulk to normalize return status codes .. Note:: We can nix this whe we drop...
{ "repo_name": "mozilla/elasticutils", "path": "elasticutils/monkeypatch.py", "copies": "2", "size": "1146", "license": "bsd-3-clause", "hash": -7957798773254024000, "line_mean": 27.65, "line_max": 74, "alpha_frac": 0.5645724258, "autogenerated": false, "ratio": 4.1521739130434785, "config_test"...
from functools import wraps from endless_pagination.settings import PAGE_LABEL, TEMPLATE_VARNAME def page_template(template, key=PAGE_LABEL): """ Decorate a view that takes a *template* and *extra_context* keyword arguments (like generic views). The template is switched to *page_template* if request i...
{ "repo_name": "unicefuganda/edtrac", "path": "edtrac_project/endless/endless_pagination/decorators.py", "copies": "5", "size": "2609", "license": "bsd-3-clause", "hash": 3492999232462531000, "line_mean": 41.7704918033, "line_max": 85, "alpha_frac": 0.6385588348, "autogenerated": false, "ratio": 4...
from functools import wraps from .err import Err def signature(*types, **kwtypes): """Type annotations and conversions for methods. Ignores first parameter. """ conversions = [(t if isinstance(t, tuple) else (t, t)) for t in types] kwconversions = {k: (t if isinstance(t, tuple) else (t, t)) ...
{ "repo_name": "drcloud/arx", "path": "arx/decorators.py", "copies": "1", "size": "1628", "license": "mit", "hash": 2935184282238328300, "line_mean": 28.6, "line_max": 74, "alpha_frac": 0.5343980344, "autogenerated": false, "ratio": 4.20671834625323, "config_test": false, "has_no_keywords": fa...
from functools import wraps from ..error import Invalid from ..util import varargs2kwargs, getArgSpec, getParameterNames import logging log = logging.getLogger(__name__) def validateDecorator( validator, method, include, exclude, onInvalid, createContext ): if include and exclude: raise SyntaxError("'i...
{ "repo_name": "doncatnip/kanone", "path": "src/kanone/adapter/native.py", "copies": "1", "size": "2441", "license": "unlicense", "hash": 8253111066359218000, "line_mean": 29.8987341772, "line_max": 100, "alpha_frac": 0.6255632937, "autogenerated": false, "ratio": 4.245217391304347, "config_test...
from functools import wraps from .exceptions import PreconditionViolationError, PostconditionViolationError def pre(condition): """ Execute a precondition function before the decorated function. The `condition` must be a callable that receives the same keyword arguments as the function it's being ap...
{ "repo_name": "Chiel92/fate", "path": "fate/contract.py", "copies": "1", "size": "1763", "license": "mit", "hash": -7841796553145705000, "line_mean": 32.9038461538, "line_max": 86, "alpha_frac": 0.643788996, "autogenerated": false, "ratio": 5.022792022792022, "config_test": false, "has_no_key...
from functools import wraps from fabric.api import env from woven.environment import server_state, set_server_state from woven.environment import version_state, set_version_state def run_once_per_node(func): """ Decorator preventing wrapped function from running more than once per host (not just interpret...
{ "repo_name": "bretth/woven", "path": "woven/decorators.py", "copies": "1", "size": "2333", "license": "bsd-3-clause", "hash": -5339528897823658000, "line_mean": 36.6451612903, "line_max": 96, "alpha_frac": 0.6099442778, "autogenerated": false, "ratio": 4.40188679245283, "config_test": false, ...
from functools import wraps from fabric import api def multisite(func): """ Mark a task as being multisite. Multisite tasks allow you to define a global configuration for multiple sites and specify the site to use when you run your command. All the dictionary keys of the given site will then be ...
{ "repo_name": "liip/fabliip", "path": "fabliip/decorators.py", "copies": "2", "size": "3028", "license": "mit", "hash": -1923773055763521000, "line_mean": 31.9130434783, "line_max": 88, "alpha_frac": 0.5231175694, "autogenerated": false, "ratio": 4.492581602373887, "config_test": false, "has_...
from functools import wraps from flask import abort, flash from flask_security import current_user from .models import db def access_required(func): """ This decorator ensures that the current user is logged in before calling the actual view. Calls the unauthorized_view_function() when the user is not lo...
{ "repo_name": "ianzimmerman/gifoff", "path": "gifoff/helpers.py", "copies": "1", "size": "1698", "license": "mit", "hash": 5487742283059357000, "line_mean": 28.8070175439, "line_max": 97, "alpha_frac": 0.6142520612, "autogenerated": false, "ratio": 4.365038560411311, "config_test": false, "ha...
# from functools import wraps # from flask import (abort, flash, redirect, render_template, request, session, # url_for) # from flask.ext.login import (current_user, login_required, login_user, # logout_user) # from flask.ext.simon import get_or_404 # import when # from...
{ "repo_name": "dirn/Secret-Santa", "path": "xmas/views.py", "copies": "1", "size": "3241", "license": "bsd-3-clause", "hash": -4442660427337287000, "line_mean": 27.4298245614, "line_max": 79, "alpha_frac": 0.6096883678, "autogenerated": false, "ratio": 3.231306081754736, "config_test": false, ...
from functools import wraps from flask import abort, g, request, Response from twilio.util import RequestValidator from calloncongress.helpers import read_context from calloncongress import settings def twilioify(validate=True): """ Decorator that validates Twilio calls and creates the call context in the r...
{ "repo_name": "sunlightlabs/calloncongress", "path": "calloncongress/decorators.py", "copies": "1", "size": "3283", "license": "bsd-3-clause", "hash": 4814583191028089000, "line_mean": 29.119266055, "line_max": 95, "alpha_frac": 0.5735607676, "autogenerated": false, "ratio": 4.553398058252427, ...
from functools import wraps from flask import abort, request, redirect from flask_login import current_user, login_url from sqlalchemy.orm.exc import NoResultFound from app import login_manager, sentry from app.constants import permission from app.models import ( Users, Responses, Files, Notes, Let...
{ "repo_name": "CityOfNewYork/NYCOpenRecords", "path": "app/lib/permission_utils.py", "copies": "1", "size": "3480", "license": "apache-2.0", "hash": -5540344306193414000, "line_mean": 27.5245901639, "line_max": 88, "alpha_frac": 0.6077586207, "autogenerated": false, "ratio": 4.339152119700748, ...
from functools import wraps from flask import Blueprint, current_app, render_template, redirect, request, url_for, flash, session, abort, jsonify from flask_login import current_user, login_required from sqlalchemy import or_, and_ from preston.xmlapi import Preston as XMLAPI from auth.shared import db, eveapi from a...
{ "repo_name": "Celeo/GETIN-Auth", "path": "auth/hr/app.py", "copies": "1", "size": "28095", "license": "mit", "hash": -6048206060843003000, "line_mean": 33.9440298507, "line_max": 127, "alpha_frac": 0.6168001424, "autogenerated": false, "ratio": 3.8666391412056154, "config_test": true, "has_n...
from functools import wraps from flask import Blueprint from flask import current_app as app # noqa from flask import redirect, render_template, request, url_for from flask_login import LoginManager, current_user, login_user, logout_user from flask_wtf import Form from sqlalchemy import func from wtforms import Passw...
{ "repo_name": "MetroTenants/squared_away_reporter", "path": "reporter/auth.py", "copies": "1", "size": "2552", "license": "mit", "hash": -3032293216430010400, "line_mean": 26.7391304348, "line_max": 75, "alpha_frac": 0.6347962382, "autogenerated": false, "ratio": 3.9261538461538463, "config_tes...
from functools import wraps from flask import Blueprint, render_template, request from flask.ext.restful import abort, fields, reqparse, marshal_with, Resource from flask.ext.security import current_user from .core import api, db from .models import Actor, Character, Series from .utils import fields_from_model bp =...
{ "repo_name": "jonafato/ivadb", "path": "ivadb/views.py", "copies": "1", "size": "5092", "license": "bsd-3-clause", "hash": -6778747540117080000, "line_mean": 28.7777777778, "line_max": 77, "alpha_frac": 0.6535742341, "autogenerated": false, "ratio": 3.7249451353328458, "config_test": false, ...
from functools import wraps from flask import Blueprint, url_for, request from uchan.lib import roles from uchan.lib.action_authorizer import NoPermissionError from uchan.lib.moderator_request import request_has_role, get_authed mod = Blueprint('mod', __name__, url_prefix='/mod', template_folder='templates', static_...
{ "repo_name": "Floens/uchan", "path": "uchan/view/mod/__init__.py", "copies": "1", "size": "1873", "license": "mit", "hash": -4358888981313848000, "line_mean": 26.9552238806, "line_max": 104, "alpha_frac": 0.5851575013, "autogenerated": false, "ratio": 3.5608365019011408, "config_test": false, ...
from functools import wraps from flask import current_app, abort, request def requires_debug(view): @wraps(view) def _(*args, **kwargs): strict = not current_app.config.get('FLASK_DEBUG_DISABLE_STRICT', False) if not current_app.debug: i...
{ "repo_name": "mbr/Flask-Debug", "path": "flask_debug/security.py", "copies": "1", "size": "1860", "license": "mit", "hash": 4075692500568659000, "line_mean": 34.7692307692, "line_max": 76, "alpha_frac": 0.4822580645, "autogenerated": false, "ratio": 4.685138539042821, "config_test": false, "...
from functools import wraps from flask import current_app, g, session as cookie_session from flask_login import current_user from flask_themes2 import render_theme_template from structlog import get_logger from app.globals import get_metadata, get_session_timeout_in_seconds from app.templating.metadata_context import...
{ "repo_name": "ONSdigital/eq-survey-runner", "path": "app/helpers/template_helper.py", "copies": "1", "size": "2812", "license": "mit", "hash": 1052785185171291300, "line_mean": 28.914893617, "line_max": 86, "alpha_frac": 0.6614509246, "autogenerated": false, "ratio": 3.846785225718194, "config...
from functools import wraps from flask import current_app, jsonify from flask_jwt import ( _jwt_required, _default_request_handler, current_identity, JWTError) from qlutter_todo.extensions import bcrypt from qlutter_todo.models.user import User def authenticate(email, password): user = User.get_by_email(ema...
{ "repo_name": "pkolios/qlutter-todo", "path": "qlutter_todo/auth/utils.py", "copies": "1", "size": "1221", "license": "mit", "hash": -8176238634338875000, "line_mean": 27.3953488372, "line_max": 73, "alpha_frac": 0.6617526618, "autogenerated": false, "ratio": 3.688821752265861, "config_test": f...
from functools import wraps from flask import current_app, redirect, request, session from oic import rndstr from oic.oic.message import EndSessionRequest from werkzeug.exceptions import BadRequest def authenticate(view_fn): @wraps(view_fn) def wrapper(*args, **kwargs): if _reauthentication_necessa...
{ "repo_name": "crossgovernmentservices/sue-my-brother", "path": "app/oidc_client/decorators.py", "copies": "1", "size": "3209", "license": "mit", "hash": -799577294563918800, "line_mean": 26.4273504274, "line_max": 78, "alpha_frac": 0.5864755376, "autogenerated": false, "ratio": 4.056890012642225...
from functools import wraps from flask import current_app, request from itsdangerous import URLSafeSerializer from app.mod_api.errors import InvalidUsage def valid_facility(f): """A decorator to return a 404 if the facilitry is not there. :param f: Function to decorate. :type f: function :return: D...
{ "repo_name": "xsteadfastx/bib-api", "path": "app/mod_api/decorators.py", "copies": "1", "size": "1372", "license": "mit", "hash": 6815000623235580000, "line_mean": 25.3846153846, "line_max": 73, "alpha_frac": 0.6253644315, "autogenerated": false, "ratio": 4.083333333333333, "config_test": fals...
from functools import wraps from flask import current_app, request from .allows import allows __all__ = ("requires", "exempt_from_requirements", "guard_entire") def _get_executing_handler(): return current_app.view_functions[request.endpoint] def _should_run_requirements(): if request.routing_exception i...
{ "repo_name": "justanr/flask-allows", "path": "src/flask_allows/views.py", "copies": "1", "size": "5753", "license": "mit", "hash": -5603187767303640000, "line_mean": 27.3399014778, "line_max": 83, "alpha_frac": 0.5758734573, "autogenerated": false, "ratio": 4.719442165709598, "config_test": fa...
from functools import wraps from flask import current_app, request from itsdangerous import BadSignature, SignatureExpired, TimestampSigner from trexmo.core.db.models import User from trexmo.core.exc import ExpiredTokenError, InvalidTokenError, PrivilegeError def parse_auth(): """Parse the authentication token...
{ "repo_name": "kyouko-taiga/trexmo", "path": "trexmo/core/utils/auth.py", "copies": "1", "size": "3013", "license": "apache-2.0", "hash": -3344817518674191000, "line_mean": 31.3978494624, "line_max": 91, "alpha_frac": 0.68503153, "autogenerated": false, "ratio": 4.243661971830986, "config_test"...
from functools import wraps from flask import current_app, url_for, g, request from social.utils import module_member, setting_name from social.strategies.utils import get_strategy DEFAULTS = { 'STORAGE': 'social.apps.flask_me_app.models.FlaskStorage', 'STRATEGY': 'social.strategies.flask_strategy.FlaskStra...
{ "repo_name": "duoduo369/python-social-auth", "path": "social/apps/flask_me_app/utils.py", "copies": "2", "size": "1279", "license": "bsd-3-clause", "hash": 5814834186077399000, "line_mean": 31.7948717949, "line_max": 73, "alpha_frac": 0.6372165754, "autogenerated": false, "ratio": 3.984423676012...
from functools import wraps from flask import current_app, url_for, g, request, redirect from social.utils import module_member, setting_name from social.strategies.utils import get_strategy DEFAULTS = { 'STORAGE': 'social.apps.flask_app.models.FlaskStorage', 'STRATEGY': 'social.strategies.flask_strategy.Fl...
{ "repo_name": "dongweiming/flask_reveal", "path": "social/apps/flask_app/utils.py", "copies": "1", "size": "1501", "license": "bsd-3-clause", "hash": -748781485152460700, "line_mean": 30.9361702128, "line_max": 73, "alpha_frac": 0.6315789474, "autogenerated": false, "ratio": 3.992021276595745, ...
from functools import wraps from flask import Flask from flask import jsonify from flask_jwt_extended import create_access_token from flask_jwt_extended import get_jwt from flask_jwt_extended import JWTManager from flask_jwt_extended import verify_jwt_in_request app = Flask(__name__) app.config["JWT_SECRET_KEY"] = ...
{ "repo_name": "vimalloc/flask-jwt-extended", "path": "examples/custom_decorators.py", "copies": "1", "size": "1288", "license": "mit", "hash": -6676005405439362000, "line_mean": 24.2549019608, "line_max": 77, "alpha_frac": 0.6529503106, "autogenerated": false, "ratio": 3.788235294117647, "confi...
from functools import wraps from flask import Flask, render_template, redirect, request from google.appengine.api import users from models import Person def render_login_template(template, **kwargs): user = users.get_current_user() if user: login_url = users.create_logout_url(request.url) ur...
{ "repo_name": "augment00/a00_registry", "path": "src/shared.py", "copies": "1", "size": "1047", "license": "mit", "hash": 6025024351126661000, "line_mean": 29.7941176471, "line_max": 94, "alpha_frac": 0.629417383, "autogenerated": false, "ratio": 3.906716417910448, "config_test": false, "has_...
from functools import wraps from flask import (Flask, render_template, request, redirect, url_for, flash, make_response, jsonify) from flask import session as login_session from sqlalchemy import create_engine, asc from sqlalchemy.orm import sessionmaker from database_setup import (Base, User, Cat...
{ "repo_name": "gnodar01/catalog", "path": "catalogizer.py", "copies": "1", "size": "36589", "license": "mit", "hash": -471585458241064700, "line_mean": 34.6965853659, "line_max": 144, "alpha_frac": 0.6042799749, "autogenerated": false, "ratio": 4.166837490035303, "config_test": false, "has_no...
from functools import wraps from flask import Flask, render_template, request, Response app = Flask(__name__) from pymongo import MongoClient from bson.objectid import ObjectId import os import json import re from utils.ara2man import ara2man # SETTINGS regexp = r'([\d同一二三四五六七八九十]+年[、同某\d一二三四五六七八九十零]*月[初間某\d卅廿一二三四...
{ "repo_name": "katrina376/wenizit", "path": "application.py", "copies": "1", "size": "9448", "license": "mit", "hash": -4865900255987709000, "line_mean": 36.4435483871, "line_max": 113, "alpha_frac": 0.5264914926, "autogenerated": false, "ratio": 3.498869630746044, "config_test": false, "has_...
from functools import wraps from flask import Flask, request, Response from flask import redirect, jsonify from flask import g from flask_jwt import verify_jwt from flask.ext.jwt import current_user from server import app, jwt, session from server.models import * # routing for basic page # @app.route('/') def basic_...
{ "repo_name": "meggers/constellate-server", "path": "server/controllers.py", "copies": "1", "size": "8917", "license": "mit", "hash": -2896941065076943400, "line_mean": 28.7233333333, "line_max": 122, "alpha_frac": 0.675787821, "autogenerated": false, "ratio": 3.768808114961961, "config_test": ...
from functools import wraps from flask import Flask, session, redirect, url_for, render_template, request, flash from flask.ext.sqlalchemy import SQLAlchemy import bcrypt app = Flask(__name__) app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///auth.db' db = SQLAlchemy(app) app.secret_key = "This is supposed to be a s...
{ "repo_name": "kryptn/FlaskBareAuth", "path": "app.py", "copies": "1", "size": "3035", "license": "mit", "hash": -720827180377481000, "line_mean": 24.7203389831, "line_max": 99, "alpha_frac": 0.6131795717, "autogenerated": false, "ratio": 3.936446173800259, "config_test": false, "has_no_keywo...
from functools import wraps from flask import g from app.constants import ( ask_to_register_answer, student_required_answer, educator_required_answer ) from app.models import User from tg_bot import bot def login_required_message(func): @wraps(func) def wrapper(message): user = User.query.filter...
{ "repo_name": "EeOneDown/spbu4u", "path": "telebot_login/__init__.py", "copies": "1", "size": "4022", "license": "apache-2.0", "hash": -7583553841568528000, "line_mean": 26.9305555556, "line_max": 77, "alpha_frac": 0.5626553953, "autogenerated": false, "ratio": 3.7765258215962443, "config_test"...
from functools import wraps from flask import g, request from flask.ext.restful import abort from app.auth.models import User def login_required(f): @wraps(f) def decorated_function(*args, **kwargs): auth_header = request.headers.get('Authorization', 'Token Null') token = [item.encode('ascii...
{ "repo_name": "bmbove/flask-api-boilerplate", "path": "app/base/decorators.py", "copies": "1", "size": "1039", "license": "mit", "hash": -8979283358412634000, "line_mean": 30.4848484848, "line_max": 73, "alpha_frac": 0.5890279115, "autogenerated": false, "ratio": 4.156, "config_test": false, ...
from functools import wraps from flask import jsonify, request, g, abort import rethinkdb as r from app import app from models.Error import Error def login_required(function_to_wrap): @wraps(function_to_wrap) def wrap(*args, **kwargs): try: if request.method == 'GET': dat...
{ "repo_name": "suparngp/letswikit", "path": "ui/controllers/menu.py", "copies": "1", "size": "5941", "license": "apache-2.0", "hash": -1478312903554988800, "line_mean": 38.8724832215, "line_max": 113, "alpha_frac": 0.561858273, "autogenerated": false, "ratio": 3.703865336658354, "config_test": ...
from functools import wraps from flask import json from config import atom_feeds def multiline_to_list(data, whitespace_separator=True, unique_only=True, filter_empty=True): if not data: return [] if whitespace_separator: data = data.replace(' ', '\n') data_list = data.replace('\r', '')....
{ "repo_name": "anthraxx/arch-security-tracker", "path": "tracker/util.py", "copies": "2", "size": "2496", "license": "mit", "hash": -5436432959109468000, "line_mean": 27.6896551724, "line_max": 92, "alpha_frac": 0.5821314103, "autogenerated": false, "ratio": 3.5404255319148934, "config_test": f...
from functools import wraps from flask import make_response from flask import Flask from flask import request, Response from OpenSSL import SSL app = Flask(__name__) users = {'admin': 'secret', 'user': 'user'} @app.before_request def before_request(): print request.headers def check_auth(username, password...
{ "repo_name": "srmelody/cachetools", "path": "traffic.py", "copies": "1", "size": "2177", "license": "apache-2.0", "hash": 2623375436654067000, "line_mean": 22.9230769231, "line_max": 75, "alpha_frac": 0.6628387689, "autogenerated": false, "ratio": 3.9509981851179674, "config_test": false, "h...
from functools import wraps from flask import make_response, render_template, request from flask_login import current_user from .utils import patch_http_cache_headers def templated(template=None): """ Taken from http://flask.pocoo.org/docs/0.10/patterns/viewdecorators/ """ def decorator(f): ...
{ "repo_name": "jazzband/website", "path": "jazzband/decorators.py", "copies": "2", "size": "1625", "license": "mit", "hash": 3002294419196657700, "line_mean": 26.0833333333, "line_max": 78, "alpha_frac": 0.6116923077, "autogenerated": false, "ratio": 4.310344827586207, "config_test": false, "...
from functools import wraps from flask import ( Blueprint, render_template, request, session, flash, abort, redirect, ) from PyPaste.utils import pypaste_url_for as url_for from PyPaste.forms import LoginForm, LogoutForm, DeletePasteForm from PyPaste.models.users import User from PyPaste.m...
{ "repo_name": "joealcorn/PyPaste", "path": "PyPaste/views/admin/__init__.py", "copies": "1", "size": "2108", "license": "mit", "hash": -1523774362370896100, "line_mean": 24.7073170732, "line_max": 64, "alpha_frac": 0.6228652751, "autogenerated": false, "ratio": 3.79136690647482, "config_test": ...
from functools import wraps from flask import redirect, request, session, url_for from app.models.user import User from app.utils.time import is_less_than_days_ago def redirect_to_sign_in(f): @wraps(f) def wrapped(*args, **kwargs): if 'user_details' not in session: return redirect(url_fo...
{ "repo_name": "alphagov/notifications-admin", "path": "app/utils/login.py", "copies": "1", "size": "1880", "license": "mit", "hash": -7922210204723726000, "line_mean": 33.1818181818, "line_max": 113, "alpha_frac": 0.6718085106, "autogenerated": false, "ratio": 3.6084452975047983, "config_test":...
from functools import wraps from flask import render_template, flash, request, redirect, url_for, session from passlib.hash import sha256_crypt from config import app, db from forms import RegisterForm, VideoForm, CommentForm from models import Users, Videos, Comments from werkzeug.contrib.fixers import ProxyFix ap...
{ "repo_name": "alaturqua/my_flask_app", "path": "app.py", "copies": "1", "size": "5848", "license": "apache-2.0", "hash": -6992586259058810000, "line_mean": 28.9897435897, "line_max": 85, "alpha_frac": 0.6241450068, "autogenerated": false, "ratio": 3.657285803627267, "config_test": false, "ha...
from functools import wraps from flask import request, Blueprint, render_template, jsonify, flash, \ redirect, url_for from sqlalchemy.orm.util import join from my_app import db, app from my_app.catalog.models import Product, Category catalog = Blueprint('catalog', __name__) def template_or_json(template=None)...
{ "repo_name": "abacuspix/NFV_project", "path": "Flask_Framework_Cookbook/Chapter-4-master/my_app/catalog/views.py", "copies": "1", "size": "3475", "license": "mit", "hash": -548645942632864800, "line_mean": 28.4491525424, "line_max": 77, "alpha_frac": 0.6509352518, "autogenerated": false, "ratio"...
from functools import wraps from flask import request, g from itsdangerous import TimedJSONWebSignatureSerializer as Serializer from itsdangerous import SignatureExpired, BadSignature from app import app from app.utils.errors import UNAUTHORIZED, FORBIDDEN TWO_WEEKS = 1209600 def generate_token(user, expiration=T...
{ "repo_name": "projectweekend/Flask-PostgreSQL-API-Seed", "path": "app/utils/auth.py", "copies": "1", "size": "1410", "license": "mit", "hash": 677453778476030100, "line_mean": 24.6363636364, "line_max": 70, "alpha_frac": 0.619858156, "autogenerated": false, "ratio": 4.0285714285714285, "config...
from functools import wraps from flask import request, g from time import time from app import app, redis from app.utils.errors import TOO_MANY_REQUESTS def rate_limit(limit=100, window=60): def decorator(func): @wraps(func) def wrapper(*args, **kwargs): key = "{0}: {1}".format(reque...
{ "repo_name": "projectweekend/Flask-PostgreSQL-API-Seed", "path": "app/utils/rate_limit.py", "copies": "1", "size": "1355", "license": "mit", "hash": -3914606792959529500, "line_mean": 27.829787234, "line_max": 70, "alpha_frac": 0.5852398524, "autogenerated": false, "ratio": 4.081325301204819, ...
from functools import wraps from flask import request, make_response, jsonify from plato.api.models import User def authenticate(f): @wraps(f) def decorated_function(*args, **kwargs): response_object = { 'status': 'error', 'message': 'Something went wrong. Please contact us.'...
{ "repo_name": "zhlooking/flask-microservices-users", "path": "plato/api/utils.py", "copies": "1", "size": "1198", "license": "mit", "hash": -7523335296702650000, "line_mean": 31.3783783784, "line_max": 69, "alpha_frac": 0.612687813, "autogenerated": false, "ratio": 4.033670033670034, "config_te...
from functools import wraps from flask import request, make_response from .exceptions import ApiError from .schemas import create_schema, ma_version_lt_300b7 def request_schema(schema_or_dict, extends=None, many=None, cache_schema=True, pass_data=False): schema_ = create_schema(schema_or_dict, extends) def...
{ "repo_name": "vgavro/flask-vgavro-utils", "path": "flask_vgavro_utils/decorators.py", "copies": "1", "size": "3120", "license": "bsd-2-clause", "hash": -3681102236099659300, "line_mean": 30.8367346939, "line_max": 96, "alpha_frac": 0.583974359, "autogenerated": false, "ratio": 4.0519480519480515...
from functools import wraps from flask import request from pydantic import ValidationError, create_model ARG_LOCATIONS = { "query": lambda: request.args, "json": lambda: request.get_json(), "form": lambda: request.form, "headers": lambda: request.headers, "cookies": lambda: request.cookies, } de...
{ "repo_name": "ajvpot/CTFd", "path": "CTFd/api/v1/helpers/request.py", "copies": "4", "size": "1925", "license": "apache-2.0", "hash": -2452650351252771300, "line_mean": 31.0833333333, "line_max": 82, "alpha_frac": 0.5667532468, "autogenerated": false, "ratio": 4.203056768558952, "config_test":...
from functools import wraps from flask import request from sqlalchemy import or_ from sqlalchemy.orm import joinedload, contains_eager, attributes from sqlalchemy.orm.exc import NoResultFound from sqlalchemy.util import KeyedTuple from .model import session_scope, Track, TrackInfo, Album, Artist, Cover def limitoff...
{ "repo_name": "magne4000/festival", "path": "festivallib/request.py", "copies": "1", "size": "9383", "license": "mit", "hash": -5717507041790010000, "line_mean": 39.7956521739, "line_max": 119, "alpha_frac": 0.5738036875, "autogenerated": false, "ratio": 4.118964003511852, "config_test": false,...
from functools import wraps from flask import request from app.main.service.auth_helper import Auth def token_required(f): @wraps(f) def decorated(*args, **kwargs): data, status = Auth.get_logged_in_user(request) token = data.get('data') if not token: return data, statu...
{ "repo_name": "i-am-dev/DojoManager", "path": "app/main/util/decorator.py", "copies": "1", "size": "1871", "license": "mit", "hash": 4084493352168170500, "line_mean": 22.3875, "line_max": 55, "alpha_frac": 0.5168359166, "autogenerated": false, "ratio": 4.423167848699763, "config_test": false, ...
from functools import wraps from flask import request from community_share.authorization import get_requesting_user from community_share.routes import base_routes def api_path(path, query_args): query = '&'.join(['{}={}'.format(name, query_args[name]) for name in query_args]) return '{base_url}rest/{path}/...
{ "repo_name": "seanastephens/communityshare", "path": "community_share/flask_helpers.py", "copies": "1", "size": "1031", "license": "mpl-2.0", "hash": -2090685932945497600, "line_mean": 25.4358974359, "line_max": 85, "alpha_frac": 0.6236663434, "autogenerated": false, "ratio": 3.8185185185185184,...
from functools import wraps from flask import request from flask.ext.restful import Api from flask.ext.restful.reqparse import RequestParser def patched_to_marshallable_type(obj): """adds __marshallable__ support; see https://github.com/twilio/flask-restful/pull/32""" if obj is None: return None # m...
{ "repo_name": "paulvisen/flask-todo", "path": "utils/flaskutils/restful.py", "copies": "2", "size": "2942", "license": "mit", "hash": 6990349651556561000, "line_mean": 42.2647058824, "line_max": 117, "alpha_frac": 0.6597552685, "autogenerated": false, "ratio": 3.8863936591809773, "config_test":...
from functools import wraps from flask import request, session from conditional.util.ldap import ldap_is_active, ldap_is_alumni, \ ldap_is_eboard, ldap_is_eval_director, \ ldap_is_financial_director, ldap_get_member, ldap_is_current_student def webauth_request(func): @wraps(func) def wrapped_func(*a...
{ "repo_name": "ComputerScienceHouse/conditional", "path": "conditional/util/auth.py", "copies": "1", "size": "1499", "license": "mit", "hash": 1636267782973045800, "line_mean": 30.8936170213, "line_max": 73, "alpha_frac": 0.5917278185, "autogenerated": false, "ratio": 3.6207729468599035, "confi...