text
stringlengths
0
1.05M
meta
dict
from functools import wraps def lazy(func): def lazy_func(self, *args, **kwargs): cached_attribute = '_cached' if not hasattr(self, cached_attribute): setattr(self, cached_attribute, {}) if func.__name__ not in getattr(self, cached_attribute): getattr(self, cached_at...
{ "repo_name": "bueda/django-comrade", "path": "comrade/functional.py", "copies": "1", "size": "1199", "license": "mit", "hash": -4100328486929083000, "line_mean": 36.46875, "line_max": 66, "alpha_frac": 0.6021684737, "autogenerated": false, "ratio": 3.892857142857143, "config_test": false, "h...
from functools import wraps def logit(logfile='out.log'): def logging_decorator(func): @wraps(func) def wrapped_function(*args, **kwargs): log_string = func.__name__ + " was called" print(log_string) # Open the logfile and append with open(logfile, 'a...
{ "repo_name": "mndarren/Code-Lib", "path": "Python_lib/pythonPractice/logDecorator.py", "copies": "1", "size": "1819", "license": "apache-2.0", "hash": 8411436289181679000, "line_mean": 26.1641791045, "line_max": 71, "alpha_frac": 0.5766904893, "autogenerated": false, "ratio": 3.4846743295019156,...
from functools import wraps def memoize(func, cache, num_args): """ Wrap a function so that results for any argument tuple are stored in 'cache'. Note that the args to the function must be usable as dictionary keys. Only the first num_args are considered when creating the key. """ def wrap...
{ "repo_name": "strogo/djpcms", "path": "djpcms/utils/functional.py", "copies": "1", "size": "9253", "license": "bsd-3-clause", "hash": 8467806824284121000, "line_mean": 34.5884615385, "line_max": 130, "alpha_frac": 0.5643575057, "autogenerated": false, "ratio": 4.540235525024534, "config_test":...
from functools import wraps def refresh(func): """ Decorator that can be applied to model method that forces a refresh of the model. Note this decorator ensures the state of the model is what is currently within the database and therefore overwrites any current field changes. For example,...
{ "repo_name": "alexhayes/django-toolkit", "path": "django_toolkit/models/decorators.py", "copies": "1", "size": "1770", "license": "mit", "hash": -3963672083450451000, "line_mean": 37.5, "line_max": 148, "alpha_frac": 0.6502824859, "autogenerated": false, "ratio": 4.154929577464789, "config_tes...
from functools import wraps def setupmethod(f): """Use this decorator for methods that change the internal state / parameters of the system, such that the eigenstates have to be recalculated. This method will reset the 'data was changed' flag""" @wraps(f) def decorated(self, *ops, **kwops): ...
{ "repo_name": "TimofeyBalashov/MagnetizationTunneling", "path": "pyatoms/core/Setup.py", "copies": "1", "size": "2338", "license": "mit", "hash": 7895009785695639000, "line_mean": 30.5945945946, "line_max": 81, "alpha_frac": 0.6398631309, "autogenerated": false, "ratio": 4.321626617375231, "con...
from functools import wraps def timecached(func): """ Décorateur permettant d'associer un cache à la fonction `func` : - la première fois que `func` est appelée, le résultat qu'elle renvoie est stocké dans le cache ; - par la suite, lorsque `func` est appelée de nouveau, c'est le résultat s...
{ "repo_name": "latour-a/efficientmc", "path": "efficientmc/utils.py", "copies": "1", "size": "3319", "license": "mit", "hash": 940781977440465400, "line_mean": 33.5052631579, "line_max": 77, "alpha_frac": 0.5918242831, "autogenerated": false, "ratio": 3.4505263157894737, "config_test": false, ...
from functools import wraps def user_passes_test(test_func, login_url=None, redirect_field_name=REDIRECT_FIELD_NAME): def decorator(view_func): @wraps(view_func, assigned=available_attrs(view_func)) def _wrapped_view(request, *args, **kwargs): if test_func(requ...
{ "repo_name": "AnthonyBriggs/Python-101", "path": "hello_python_source_py3/chapter 07/user_passes_test.py", "copies": "2", "size": "1242", "license": "mit", "hash": -4778184909556162000, "line_mean": 30.05, "line_max": 59, "alpha_frac": 0.5982286634, "autogenerated": false, "ratio": 3.91798107255...
from functools import wraps def validate_params(valid_options, params): """ Helps us validate the parameters for the request :param valid_options: a list of strings of valid options for the api request :param params: a dict, the key-value store which we really only care about...
{ "repo_name": "gcd0318/pytumblr", "path": "pytumblr/helpers.py", "copies": "7", "size": "1734", "license": "apache-2.0", "hash": 9012486638342097000, "line_mean": 35.125, "line_max": 82, "alpha_frac": 0.6320645905, "autogenerated": false, "ratio": 3.949886104783599, "config_test": false, "has...
from functools import wraps DO = 1 SEND = 2 CALL = 3 RETURN = 4 TRY = 5 LOOP = 6 GET_STATE = 7 GLOBAL = "__GLOBAL__" DONT_RETURN = "__DONT_RETURN__" def workflow(f): @wraps(f) def _workflow(*args, **kwargs): state = {} excepts = {} global send_command, send send = None ...
{ "repo_name": "runekaagaard/workflows", "path": "workflows/__init__.py", "copies": "1", "size": "1839", "license": "unlicense", "hash": 5627648623299331000, "line_mean": 26.0588235294, "line_max": 68, "alpha_frac": 0.450788472, "autogenerated": false, "ratio": 5.224431818181818, "config_test": ...
from functools import wraps from aiohttp.abc import AbstractView from aiohttp.web import HTTPForbidden, json_response, StreamResponse try: import ujson as json except ImportError: import json from .cfg import cfg from .utils import url_for, redirect, get_cur_user def _get_request(args): # Supports class...
{ "repo_name": "imbolc/aiohttp-login", "path": "aiohttp_login/decorators.py", "copies": "1", "size": "1959", "license": "isc", "hash": -4827226534677620000, "line_mean": 27.3913043478, "line_max": 72, "alpha_frac": 0.6625829505, "autogenerated": false, "ratio": 3.9979591836734696, "config_test":...
from functools import wraps from aiohttp.web import HTTPBadRequest from . import schema, list_schema from .utils import parse_qs from .autils import mark_coro from .vdecorator import ValidationDecorator, ErrorHandler, mergeof from .errors import error_to_json from .ast_transformer import import_module import_module(...
{ "repo_name": "baverman/covador", "path": "covador/aiohttp.py", "copies": "1", "size": "1598", "license": "mit", "hash": 2096776840539917000, "line_mean": 29.7307692308, "line_max": 89, "alpha_frac": 0.7108886108, "autogenerated": false, "ratio": 3.5353982300884956, "config_test": false, "has...
from functools import wraps from alembic.migration import MigrationContext from alembic.operations import Operations import sqlalchemy as sa from toolz.curried import do, operator as op from catalyst.assets.asset_writer import write_version_info from catalyst.errors import AssetDBImpossibleDowngrade from catalyst.uti...
{ "repo_name": "enigmampc/catalyst", "path": "catalyst/assets/asset_db_migrations.py", "copies": "1", "size": "10230", "license": "apache-2.0", "hash": 2832154078629196300, "line_mean": 31.3734177215, "line_max": 78, "alpha_frac": 0.6013685239, "autogenerated": false, "ratio": 3.9743589743589745, ...
from functools import wraps from alembic.migration import MigrationContext from alembic.operations import Operations import sqlalchemy as sa from toolz.curried import do, operator as op from zipline.assets.asset_writer import write_version_info from zipline.errors import AssetDBImpossibleDowngrade from zipline.utils....
{ "repo_name": "magne-max/zipline-ja", "path": "zipline/assets/asset_db_migrations.py", "copies": "1", "size": "10135", "license": "apache-2.0", "hash": -2870723432412469000, "line_mean": 31.5884244373, "line_max": 78, "alpha_frac": 0.600197336, "autogenerated": false, "ratio": 3.999605367008682, ...
from functools import wraps from allura import model as M from ming.orm.ormsession import ThreadLocalORMSession from pylons import c def with_user_project(username): def _with_user_project(func): @wraps(func) def wrapped(*args, **kw): user = M.User.by_username(username) c...
{ "repo_name": "leotrubach/sourceforge-allura", "path": "Allura/allura/tests/decorators.py", "copies": "1", "size": "2342", "license": "apache-2.0", "hash": -566391402208446600, "line_mean": 35.59375, "line_max": 101, "alpha_frac": 0.584970111, "autogenerated": false, "ratio": 3.5112443778110944, ...
from functools import wraps from allure_commons._core import plugin_manager from allure_commons.types import LabelType, LinkType from allure_commons.utils import uuid4 from allure_commons.utils import func_parameters def safely(result): if result: return result[0] else: def dummy(function): ...
{ "repo_name": "igogorek/allure-python", "path": "allure-python-commons/src/_allure.py", "copies": "1", "size": "6092", "license": "apache-2.0", "hash": 7544402440775331000, "line_mean": 30.0816326531, "line_max": 119, "alpha_frac": 0.5697636244, "autogenerated": false, "ratio": 3.937944408532644,...
from functools import wraps from app import db, app from app.models.mollie import Transaction from flask import url_for from flask_login import current_user from flask_babel import _ from mollie.api.client import Client from mollie.api.error import Error as MollieError import itertools import logging _logger = lo...
{ "repo_name": "viaict/viaduct", "path": "app/utils/mollie.py", "copies": "1", "size": "3417", "license": "mit", "hash": -7251080151420198000, "line_mean": 29.5089285714, "line_max": 75, "alpha_frac": 0.587357331, "autogenerated": false, "ratio": 4.097122302158273, "config_test": false, "has_n...
from functools import wraps from avocado.utils.iter import ins def _check_iter(func): @wraps(func) def decorator(*args, **kwargs): val = func(*args, **kwargs) if not ins(val): raise TypeError for e in val: if not ins(e) or len(e) != 2: raise Type...
{ "repo_name": "pombredanne/django-avocado", "path": "avocado/fields/evaluators.py", "copies": "1", "size": "1254", "license": "bsd-3-clause", "hash": -9003387830206275000, "line_mean": 22.2222222222, "line_max": 60, "alpha_frac": 0.5645933014, "autogenerated": false, "ratio": 3.743283582089552, ...
from functools import wraps from backend.components.base_component import BaseComponent from backend.components.clock import Clock from backend.components.modbus_network import ModbusNetwork from backend.misc.sys_types import Mt, Et class AddElementError(Exception): def __init__(self, msg): self.msg = ms...
{ "repo_name": "dzon4xx/system", "path": "backend/components/module.py", "copies": "1", "size": "8924", "license": "mit", "hash": -153626750806933500, "line_mean": 33.3230769231, "line_max": 158, "alpha_frac": 0.5921111609, "autogenerated": false, "ratio": 3.8986456968108345, "config_test": fals...
from functools import wraps from .blueprints import NodeBlueprint, TangledSource, TangledSelf from .exceptions import NodeError __all__ = ['Tangled'] class TangleMeta(type): @classmethod def __prepare__(mcs, name, bases): """ Setting up class attributes so they are available when the a tang...
{ "repo_name": "ltron/tangle", "path": "tangle/tangled.py", "copies": "1", "size": "2244", "license": "mit", "hash": 1347157180407395000, "line_mean": 28.1428571429, "line_max": 76, "alpha_frac": 0.5891265597, "autogenerated": false, "ratio": 4.533333333333333, "config_test": false, "has_no_ke...
from functools import wraps from botocore.paginate import TokenDecoder, TokenEncoder from six.moves import reduce from .exceptions import InvalidToken PAGINATION_MODEL = { "list_executions": { "input_token": "next_token", "limit_key": "max_results", "limit_default": 100, "page_end...
{ "repo_name": "william-richard/moto", "path": "moto/stepfunctions/utils.py", "copies": "2", "size": "5391", "license": "apache-2.0", "hash": 3455755184579512000, "line_mean": 35.4256756757, "line_max": 87, "alpha_frac": 0.5945093675, "autogenerated": false, "ratio": 4.077912254160363, "config_t...
from functools import wraps from cached_httpbl.middleware import CachedHTTPBLViewMiddleware from django.utils.decorators import available_attrs, decorator_from_middleware cached_httpbl_protect = decorator_from_middleware(CachedHTTPBLViewMiddleware) cached_httpbl_protect.__name__ = "cached_httpbl_protect" cached_http...
{ "repo_name": "dlancer/django-cached-httpbl", "path": "cached_httpbl/decorators.py", "copies": "1", "size": "1071", "license": "bsd-3-clause", "hash": 4098039014920940000, "line_mean": 40.1923076923, "line_max": 83, "alpha_frac": 0.7516339869, "autogenerated": false, "ratio": 3.8664259927797833, ...
from functools import wraps from .cd import cd from .needy import ConfiguredNeedy from .platforms import available_platforms from .utility import DummyContextManager try: from exceptions import NotImplementedError except ImportError: pass class Command: def name(self): raise NotImplementedError(...
{ "repo_name": "ccbrown/needy", "path": "needy/command.py", "copies": "3", "size": "3000", "license": "mit", "hash": -8713377419375800000, "line_mean": 37.961038961, "line_max": 173, "alpha_frac": 0.701, "autogenerated": false, "ratio": 4.126547455295736, "config_test": false, "has_no_keywords...
from functools import wraps from cms.api import get_page_draft from cms.cache.permissions import get_permission_cache, set_permission_cache from cms.constants import GRANT_ALL_PERMISSIONS from cms.models import Page, Placeholder from cms.utils import get_current_site from cms.utils.compat.dj import available_attrs fro...
{ "repo_name": "rsalmaso/django-cms", "path": "cms/utils/page_permissions.py", "copies": "2", "size": "14521", "license": "bsd-3-clause", "hash": -7930601829181359000, "line_mean": 27.4725490196, "line_max": 95, "alpha_frac": 0.6439639143, "autogenerated": false, "ratio": 3.6068057625434675, "co...
from functools import wraps from .compat import text b_int = int idfunc = lambda v: v class ValidateError(ValueError): def __init__(self, message, errors): ValueError.__init__(self, message) self.errors = errors def check(func, message=None): message = message or 'Invalid value' @wraps...
{ "repo_name": "baverman/former", "path": "former/types.py", "copies": "1", "size": "1371", "license": "mit", "hash": 1585133809359635700, "line_mean": 19.1617647059, "line_max": 47, "alpha_frac": 0.5820568928, "autogenerated": false, "ratio": 3.997084548104956, "config_test": false, "has_no_k...
from functools import wraps from concurrent.futures import ThreadPoolExecutor class Tomorrow(): def __init__(self, future, timeout): self._future = future self._timeout = timeout def __getattr__(self, name): if name == '_wait': return self._future.result elif...
{ "repo_name": "samstav/Tomorrow", "path": "tomorrow/__init__.py", "copies": "1", "size": "1110", "license": "mit", "hash": -2296204235725220400, "line_mean": 24.2272727273, "line_max": 55, "alpha_frac": 0.5306306306, "autogenerated": false, "ratio": 4.475806451612903, "config_test": false, "h...
from functools import wraps from concurrent.futures import ThreadPoolExecutor class Tomorrow(): def __init__(self, future, timeout): self._future = future self._timeout = timeout def __getattr__(self, name): result = self._future.result(self._timeout) return result.__getattr...
{ "repo_name": "DOTOCA/Tomorrow", "path": "tomorrow/tomorrow.py", "copies": "1", "size": "1031", "license": "mit", "hash": -618548139918180500, "line_mean": 23.5476190476, "line_max": 51, "alpha_frac": 0.5480116392, "autogenerated": false, "ratio": 4.331932773109243, "config_test": false, "has...
from functools import wraps from corehq.apps.userreports.exceptions import BadSpecError def equal(input, reference): return input == reference def not_equal(input, reference): return input != reference def in_multiselect(input, reference): return reference in (input or '').split(' ') def any_in_mul...
{ "repo_name": "qedsoftware/commcare-hq", "path": "corehq/apps/userreports/operators.py", "copies": "1", "size": "1525", "license": "bsd-3-clause", "hash": 5396227295519320000, "line_mean": 20.7857142857, "line_max": 81, "alpha_frac": 0.6249180328, "autogenerated": false, "ratio": 3.78411910669975...
from functools import wraps from .core import Sort, Attribute from .exceptions import ArgumentError, RewritingError class Strategy(Sort): pass def set_operation(fn): @wraps(fn) def wrapper(self, terms): if not isinstance(terms, (set, frozenset)): terms = set([terms]) rv = s...
{ "repo_name": "kyouko-taiga/stew", "path": "stew/strategies.py", "copies": "1", "size": "2251", "license": "apache-2.0", "hash": 1766211907181539800, "line_mean": 22.9468085106, "line_max": 96, "alpha_frac": 0.5375388716, "autogenerated": false, "ratio": 4.100182149362477, "config_test": false,...
from functools import wraps from defer import inline_callbacks, defer, return_value from pycloudia.rest.consts import SPEC_ATTRIBUTE_NAME, METHOD, RENDERER from pycloudia.rest.spec import Spec from pycloudia.utils.decorators import generate_list, generate_dict __all__ = ['rest', 'jsonify'] def get_or_create_spec(f...
{ "repo_name": "cordis/pycloudia", "path": "pycloudia/rest/decorators.py", "copies": "1", "size": "4775", "license": "mit", "hash": -1029178175978256800, "line_mean": 28.475308642, "line_max": 81, "alpha_frac": 0.5331937173, "autogenerated": false, "ratio": 4.2520035618878005, "config_test": fal...
from functools import wraps from django.conf import settings from django.contrib.auth import REDIRECT_FIELD_NAME from django.contrib.auth.views import redirect_to_login from django.core.exceptions import PermissionDenied, ImproperlyConfigured, FieldError from django.shortcuts import get_object_or_404 from django.utils...
{ "repo_name": "smcoll/django-rules", "path": "rules/contrib/views.py", "copies": "1", "size": "6294", "license": "mit", "hash": -4405005259050757000, "line_mean": 38.835443038, "line_max": 119, "alpha_frac": 0.6480775342, "autogenerated": false, "ratio": 4.379958246346555, "config_test": false,...
from functools import wraps from django.conf import settings from django.contrib.auth import REDIRECT_FIELD_NAME from django.core.exceptions import ObjectDoesNotExist from django.http import HttpResponseRedirect, HttpResponseForbidden from django.shortcuts import render_to_response, get_object_or_404 from django.utils...
{ "repo_name": "wpjesus/codematch", "path": "ietf/secr/utils/decorators.py", "copies": "1", "size": "4106", "license": "bsd-3-clause", "hash": 3047110548831974400, "line_mean": 37.7358490566, "line_max": 130, "alpha_frac": 0.6395518753, "autogenerated": false, "ratio": 3.9480769230769233, "confi...
from functools import wraps from django.conf import settings from django.contrib.auth import REDIRECT_FIELD_NAME from django.core.exceptions import PermissionDenied from django.shortcuts import resolve_url from django.utils import six from django.utils.decorators import available_attrs from django.utils.six.moves.urll...
{ "repo_name": "GitAngel/django", "path": "django/contrib/auth/decorators.py", "copies": "356", "size": "3049", "license": "bsd-3-clause", "hash": 1720121370879008300, "line_mean": 39.6533333333, "line_max": 91, "alpha_frac": 0.6667759921, "autogenerated": false, "ratio": 4.2703081232493, "confi...
from functools import wraps from django.conf import settings from django.contrib.auth.mixins import PermissionRequiredMixin as DjangoPermissionRequiredMixin from django.contrib.auth.models import Permission from django.core.exceptions import PermissionDenied from django.shortcuts import get_object_or_404, resolve_url ...
{ "repo_name": "oogles/djem", "path": "djem/auth.py", "copies": "2", "size": "12369", "license": "bsd-3-clause", "hash": 3288527703864673000, "line_mean": 39.4215686275, "line_max": 97, "alpha_frac": 0.5821812596, "autogenerated": false, "ratio": 4.617021276595745, "config_test": false, "has_n...
from functools import wraps from django.conf import settings from django.contrib.contenttypes.fields import GenericForeignKey from django.contrib.contenttypes.models import ContentType from django.db import models as django_models from django.db import transaction from django.utils.translation import ugettext_lazy as ...
{ "repo_name": "opennode/waldur-mastermind", "path": "src/waldur_core/core/mixins.py", "copies": "2", "size": "3807", "license": "mit", "hash": 3942699631682705000, "line_mean": 29.7016129032, "line_max": 85, "alpha_frac": 0.6593117941, "autogenerated": false, "ratio": 4.3508571428571425, "confi...
from functools import wraps from django.conf import settings from django.core.cache import cache from django.db import DatabaseError from bedrock.events.models import Event CACHE_TIMEOUT = getattr(settings, 'EVENTS_CACHE_TIMEOUT', 15 * 60) def cache_memoized(obj): """ Uses the django default cache backend...
{ "repo_name": "sylvestre/bedrock", "path": "bedrock/events/utils.py", "copies": "13", "size": "2122", "license": "mpl-2.0", "hash": -7289391493525333000, "line_mean": 25.525, "line_max": 82, "alpha_frac": 0.6573986805, "autogenerated": false, "ratio": 3.9812382739212007, "config_test": false, ...
from functools import wraps from django.conf import settings from django.core.cache import cache from django.template.response import ContentNotRenderedError def cache_view(view_func): @wraps(view_func) def _wrapped_view_func(view: 'CachedApiView', *args, **kwargs): request = view.request ca...
{ "repo_name": "dreipol/djangocms-spa", "path": "djangocms_spa/decorators.py", "copies": "1", "size": "1453", "license": "mit", "hash": 6800751179321883000, "line_mean": 31.2888888889, "line_max": 107, "alpha_frac": 0.6338609773, "autogenerated": false, "ratio": 4.081460674157303, "config_test":...
from functools import wraps from django.conf import settings from django.core.cache import cache from bedrock.events.models import Event CACHE_TIMEOUT = getattr(settings, 'EVENTS_CACHE_TIMEOUT', 15 * 60) def cache_memoized(obj): """ Uses the django default cache backend to memoize results from function, ...
{ "repo_name": "jpetto/bedrock", "path": "bedrock/events/utils.py", "copies": "6", "size": "1803", "license": "mpl-2.0", "hash": 7782512981520071000, "line_mean": 27.171875, "line_max": 82, "alpha_frac": 0.6777592901, "autogenerated": false, "ratio": 3.78781512605042, "config_test": false, "ha...
from functools import wraps from django.conf import settings from django.core.exceptions import ValidationError from django.http import HttpResponse import django.views.decorators.csrf import yaml from canvas import url_util from canvas.exceptions import ServiceError, DeactivatedUserError from canvas.shortcuts import...
{ "repo_name": "drawquest/drawquest-web", "path": "website/canvas/api_decorators.py", "copies": "1", "size": "7676", "license": "bsd-3-clause", "hash": -6151146079242919000, "line_mean": 39.6137566138, "line_max": 146, "alpha_frac": 0.6377019281, "autogenerated": false, "ratio": 4.243228302929795,...
from functools import wraps from django.conf import settings from django.core import mail from django.test.utils import override_settings from mock import MagicMock, patch from nose.tools import eq_ from fjord.base.tests import TestCase, skip_if from fjord.translations import gengo_utils from fjord.translations.mode...
{ "repo_name": "DESHRAJ/fjord", "path": "fjord/translations/tests/test_gengo.py", "copies": "1", "size": "32253", "license": "bsd-3-clause", "hash": -2115790827020943000, "line_mean": 35.5266138165, "line_max": 79, "alpha_frac": 0.4988683223, "autogenerated": false, "ratio": 3.8097094259390505, ...
from functools import wraps from django.conf import settings from django.core.urlresolvers import reverse from django.http import Http404 from social.utils import setting_name, module_member from social.exceptions import MissingBackend from social.strategies.utils import get_strategy BACKENDS = settings.AUTHENTICAT...
{ "repo_name": "imsparsh/python-social-auth", "path": "social/apps/django_app/utils.py", "copies": "2", "size": "1836", "license": "bsd-3-clause", "hash": 6424553586760583000, "line_mean": 33, "line_max": 75, "alpha_frac": 0.651416122, "autogenerated": false, "ratio": 4.511056511056511, "config_...
from functools import wraps from django.conf import settings from django.core.urlresolvers import reverse from saml_service_provider import views as samlviews from .settings import LastPassServiceProviderSettings def proxy_port(f): ''' Patch saml_service_provider port setting saml_service_provider trus...
{ "repo_name": "codetry/lpsp", "path": "lpsp/views.py", "copies": "1", "size": "4043", "license": "mit", "hash": 7315921980774983000, "line_mean": 36.4351851852, "line_max": 85, "alpha_frac": 0.6215681425, "autogenerated": false, "ratio": 3.959843290891283, "config_test": false, "has_no_keywor...
from functools import wraps from django.conf import settings from django.core.urlresolvers import reverse from social.utils import setting_name, module_member from social.strategies.utils import get_strategy BACKENDS = settings.AUTHENTICATION_BACKENDS STRATEGY = getattr(settings, setting_name('STRATEGY'), ...
{ "repo_name": "nvbn/python-social-auth", "path": "social/apps/django_app/utils.py", "copies": "1", "size": "1548", "license": "bsd-3-clause", "hash": 6341045033286452000, "line_mean": 32.652173913, "line_max": 79, "alpha_frac": 0.6698966408, "autogenerated": false, "ratio": 4.161290322580645, "...
from functools import wraps from django.conf import settings from django.db import transaction from django.shortcuts import get_object_or_404, redirect from prices import Money, TaxedMoney from ..account.utils import store_user_address from ..checkout import AddressType from ..core.utils.taxes import ( ZERO_MONEY...
{ "repo_name": "UITools/saleor", "path": "saleor/order/utils.py", "copies": "1", "size": "10953", "license": "bsd-3-clause", "hash": 3260131095289705500, "line_mean": 33.7714285714, "line_max": 79, "alpha_frac": 0.6831918196, "autogenerated": false, "ratio": 3.9370956146657083, "config_test": fa...
from functools import wraps from django.conf import settings from django.db import transaction from django.utils import timezone from django.utils.translation import pgettext from prices import Money, TaxedMoney from ..core.taxes import zero_money from ..core.weight import zero_weight from ..discount.models import No...
{ "repo_name": "maferelo/saleor", "path": "saleor/order/utils.py", "copies": "1", "size": "11213", "license": "bsd-3-clause", "hash": -3411526262572477400, "line_mean": 34.1504702194, "line_max": 86, "alpha_frac": 0.654418978, "autogenerated": false, "ratio": 3.99607982893799, "config_test": fal...
from functools import wraps from django.conf import settings from django.http import Http404, HttpResponse, HttpResponseForbidden from django.utils import simplejson __all__ = ( 'ajax_only', 'ajax_login_required', 'ajax_template', 'auth_user_only', 'debug_only', 'render_to_json_response', 'super_user_only', )...
{ "repo_name": "sprymak/metacorus-django-utils", "path": "mcutils/django/decorators.py", "copies": "1", "size": "4293", "license": "mit", "hash": 7719613405355558000, "line_mean": 31.7709923664, "line_max": 79, "alpha_frac": 0.5923596553, "autogenerated": false, "ratio": 4.167961165048544, "conf...
from functools import wraps from django.conf import settings from django.http import HttpRequest, HttpResponse, HttpResponseForbidden, HttpResponseNotAllowed from django.views.decorators.csrf import csrf_exempt from twilio.request_validator import RequestValidator from twilio.rest import Client from site_config.model...
{ "repo_name": "monty5811/apostello", "path": "apostello/twilio.py", "copies": "1", "size": "3240", "license": "mit", "hash": 4085001207252195000, "line_mean": 35, "line_max": 106, "alpha_frac": 0.6450617284, "autogenerated": false, "ratio": 4.53781512605042, "config_test": true, "has_no_keywo...
from functools import wraps from django.conf import settings from django.http.response import Http404 from django.utils.safestring import mark_safe from django.utils.translation import ugettext from django.utils.encoding import force_text from django.urls import NoReverseMatch from pyston.conf import settings as pyst...
{ "repo_name": "matllubos/django-is-core", "path": "is_core/rest/resource.py", "copies": "1", "size": "17557", "license": "bsd-3-clause", "hash": -5545740911404321000, "line_mean": 37.5868131868, "line_max": 123, "alpha_frac": 0.6388335137, "autogenerated": false, "ratio": 3.9993166287015947, "c...
from functools import wraps from django.conf import settings from django.shortcuts import render def short_circuit_middlewares(view_func): """ Marks a view function as wanting to short circuit middlewares. """ # Based on Django's csrf_exempt # We could just do view_func.short_circuit_middlewares...
{ "repo_name": "rehandalal/morgoth", "path": "morgoth/base/decorators.py", "copies": "1", "size": "1058", "license": "mpl-2.0", "hash": 5191686070378484000, "line_mean": 30.1176470588, "line_max": 72, "alpha_frac": 0.6720226843, "autogenerated": false, "ratio": 3.847272727272727, "config_test": ...
from functools import wraps from django.conf import settings from django.shortcuts import render, redirect from django.contrib import messages from django.contrib.auth.forms import SetPasswordForm from django.contrib.auth import update_session_auth_hash, views as auth_views from django.http import Http404 from django....
{ "repo_name": "Tivix/wagtail", "path": "wagtail/wagtailadmin/views/account.py", "copies": "1", "size": "5038", "license": "bsd-3-clause", "hash": 7791695660118980000, "line_mean": 36.0441176471, "line_max": 105, "alpha_frac": 0.7137753077, "autogenerated": false, "ratio": 4.226510067114094, "co...
from functools import wraps from django.conf import settings from django.template.loader import render_to_string from django.utils import six from .utils import get_tag_id, set_lazy_tag_data def _get_func_name(func): if six.PY2: return func.func_name else: return func.__name__ def lazy_tag...
{ "repo_name": "grantmcconnaughey/django-lazy-tags", "path": "lazy_tags/decorators.py", "copies": "1", "size": "1098", "license": "mit", "hash": -3510234422876530700, "line_mean": 27.8947368421, "line_max": 75, "alpha_frac": 0.5701275046, "autogenerated": false, "ratio": 3.7094594594594597, "con...
from functools import wraps from django.conf import settings from django.utils import translation class classproperty(property): def __get__(self, cls, owner): return self.fget.__get__(None, owner)() def singleton(klass): """ Create singleton from class """ instances = {} def geti...
{ "repo_name": "druids/django-chamber", "path": "chamber/utils/decorators.py", "copies": "1", "size": "1159", "license": "bsd-3-clause", "hash": -7803607456464232000, "line_mean": 25.3409090909, "line_max": 72, "alpha_frac": 0.6307161346, "autogenerated": false, "ratio": 4.617529880478088, "conf...
from functools import wraps from django.conf import settings from rest_framework import status from rest_framework.response import Response SETTINGS = getattr(settings, 'DJANGO_REST_PARAMS', {}) TRUE_VALUES = SETTINGS.get('TRUE_VALUES', ('1', 'true')) FALSE_VALUES = SETTINGS.get('FALSE_VALUES', ('0', 'false')) def ...
{ "repo_name": "pombredanne/django-rest-params", "path": "django_rest_params/decorators.py", "copies": "1", "size": "9621", "license": "bsd-3-clause", "hash": 2564168134608042000, "line_mean": 39.4243697479, "line_max": 149, "alpha_frac": 0.4867477393, "autogenerated": false, "ratio": 4.6299326275...
from functools import wraps from django.conf import settings import json import requests from gengo import Gengo, GengoError # Cache of supported languages from Gengo. Theoretically, these don't # change often, so the first time we request it, we cache it and then # keep that until the next deployment. GENGO_LANGUA...
{ "repo_name": "rlr/fjord", "path": "fjord/translations/gengo_utils.py", "copies": "1", "size": "11859", "license": "bsd-3-clause", "hash": 3328444559626982400, "line_mean": 31.9416666667, "line_max": 79, "alpha_frac": 0.5861371111, "autogenerated": false, "ratio": 4.159593125219222, "config_tes...
from functools import wraps from django.conf import settings import json import requests from gengo import Gengo, GengoError # noqa # Cache of supported languages from Gengo. Theoretically, these don't # change often, so the first time we request it, we cache it and then # keep that until the next deployment. GENG...
{ "repo_name": "mozilla/fjord", "path": "fjord/translations/gengo_utils.py", "copies": "5", "size": "9701", "license": "bsd-3-clause", "hash": -4133347542340424700, "line_mean": 29.9936102236, "line_max": 79, "alpha_frac": 0.5958148644, "autogenerated": false, "ratio": 4.052213868003341, "config...
from functools import wraps from django.conf.urls import url from django.views.decorators.csrf import csrf_exempt from oslo_utils import importutils methods={} def register(path): def decorate(func): # print(path,func,name or func.__qualname__) methods[path]=func @wraps(func) def wrapper(*args,**k...
{ "repo_name": "hikelee/launcher", "path": "launcher/views/bases/register.py", "copies": "1", "size": "1092", "license": "mit", "hash": -1306226507628266200, "line_mean": 22.7391304348, "line_max": 88, "alpha_frac": 0.6611721612, "autogenerated": false, "ratio": 3.52258064516129, "config_test": ...
from functools import wraps from django.contrib.auth.decorators import login_required from django.contrib import messages from django.urls import reverse from django.http.response import HttpResponseForbidden, HttpResponseRedirect from django.shortcuts import get_object_or_404, redirect, render from django.utils.trans...
{ "repo_name": "jsmesami/naovoce", "path": "src/fruit/views.py", "copies": "1", "size": "3348", "license": "bsd-3-clause", "hash": 5914304660239898000, "line_mean": 27.1344537815, "line_max": 97, "alpha_frac": 0.6367980884, "autogenerated": false, "ratio": 3.800227014755959, "config_test": false...
from functools import wraps from django.contrib.auth.decorators import login_required, permission_required, user_passes_test from django.contrib.admin.views.decorators import staff_member_required from django.http import HttpResponse, HttpRequest from django.utils.decorators import method_decorator from django.utils.f...
{ "repo_name": "jamespacileo/django-france", "path": "tests/regressiontests/decorators/tests.py", "copies": "2", "size": "6249", "license": "bsd-3-clause", "hash": 8930933596405351000, "line_mean": 33.5248618785, "line_max": 96, "alpha_frac": 0.6682669227, "autogenerated": false, "ratio": 3.908067...
from functools import wraps from django.contrib.auth.decorators import user_passes_test from .conf import settings def trusted_agent_required(view=None, redirect_field_name='next', login_url=None): """ Similar to :func:`~django.contrib.auth.decorators.login_required`, but requires ``request.agent.is_tru...
{ "repo_name": "hany55/django-agent-trust", "path": "django_agent_trust/decorators.py", "copies": "1", "size": "1039", "license": "bsd-2-clause", "hash": -8533121744416887000, "line_mean": 34.8275862069, "line_max": 82, "alpha_frac": 0.6737247353, "autogenerated": false, "ratio": 3.965648854961832...
from functools import wraps from django.contrib.auth import authenticate from django.contrib.auth.models import AnonymousUser def basic_authentication(view_method): '''This decorator performs Basic Authentication when an HTTP_AUTHORIZATION header is set in the request. If no credentials are present or authen...
{ "repo_name": "emory-libraries/pidman", "path": "pidman/rest_api/decorators.py", "copies": "1", "size": "1410", "license": "apache-2.0", "hash": -3406749494854870500, "line_mean": 43.09375, "line_max": 84, "alpha_frac": 0.690070922, "autogenerated": false, "ratio": 4.37888198757764, "config_tes...
from functools import wraps from django.contrib.auth import REDIRECT_FIELD_NAME from django.contrib.auth.decorators import user_passes_test from django.http import HttpResponseForbidden, Http404 from django.shortcuts import get_object_or_404, redirect as django_redirect from .security import detect_permissions, Globa...
{ "repo_name": "hirokiky/django-keeper", "path": "keeper/views.py", "copies": "1", "size": "3764", "license": "mit", "hash": -8115164274362194000, "line_mean": 27.9538461538, "line_max": 77, "alpha_frac": 0.6235387885, "autogenerated": false, "ratio": 4.31651376146789, "config_test": false, "h...
from functools import wraps 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 from django.core.exceptions import PermissionDenied...
{ "repo_name": "MrReN/django-oscar", "path": "oscar/views/decorators.py", "copies": "3", "size": "4759", "license": "bsd-3-clause", "hash": -9005110938301099000, "line_mean": 38.3305785124, "line_max": 79, "alpha_frac": 0.6743013238, "autogenerated": false, "ratio": 4.299006323396568, "config_te...
from functools import wraps from django.contrib.auth import REDIRECT_FIELD_NAME from django.shortcuts import redirect, resolve_url from django.utils.decorators import available_attrs from django.utils.encoding import force_str from django.utils.six.moves.urllib.parse import urlparse def user_passes_test(function=Non...
{ "repo_name": "AASHE/django-bulletin", "path": "bulletin/decorators.py", "copies": "1", "size": "1832", "license": "mit", "hash": -2528940185856585700, "line_mean": 41.6046511628, "line_max": 75, "alpha_frac": 0.643558952, "autogenerated": false, "ratio": 4.211494252873563, "config_test": true,...
from functools import wraps from django.contrib.auth.mixins import AccessMixin, LoginRequiredMixin from django.core.exceptions import PermissionDenied from django.shortcuts import redirect def sales_access_required(function): """ this function is a decorator used to authorize if a user has sales access """ ...
{ "repo_name": "MicroPyramid/Django-CRM", "path": "common/access_decorators_mixins.py", "copies": "1", "size": "2689", "license": "mit", "hash": 6570156226098466000, "line_mean": 29.908045977, "line_max": 89, "alpha_frac": 0.6110078096, "autogenerated": false, "ratio": 4.511744966442953, "config...
from functools import wraps from django.contrib.auth.models import Group, Permission, User from django.test import TestCase from django.urls import reverse from wagtail.core.models import GroupPagePermission, Page from wagtail.tests.utils import WagtailTestUtils from tests.app.models import NewsIndex, NewsItem, Secon...
{ "repo_name": "takeflight/wagtailnews", "path": "tests/test_permissions.py", "copies": "1", "size": "12351", "license": "bsd-2-clause", "hash": -2225936659990687500, "line_mean": 36.8865030675, "line_max": 78, "alpha_frac": 0.6517690875, "autogenerated": false, "ratio": 3.9036030341340076, "con...
from functools import wraps from django.contrib.auth.models import User from django.core.urlresolvers import reverse_lazy from django.http import JsonResponse from django.views.generic.edit import UpdateView as BaseUpdateView, CreateView as BaseCreateView, DeleteView as BaseDeleteView from django.contrib import messag...
{ "repo_name": "awemulya/fieldsight-kobocat", "path": "onadata/apps/fieldsight/mixins.py", "copies": "1", "size": "17259", "license": "bsd-2-clause", "hash": -3584811459260159500, "line_mean": 40.5903614458, "line_max": 127, "alpha_frac": 0.6236166638, "autogenerated": false, "ratio": 4.2311841137...
from functools import wraps from django.contrib.auth.models import User from django.http import HttpResponse, HttpResponseForbidden from git.service import GIT_SERVICE_RECEIVE_PACK, GIT_SERVICE_UPLOAD_PACK from repository.models import Repository, RepositoryAccess from user.auth import base_auth def git_access_requ...
{ "repo_name": "Djacket/djacket", "path": "core/backend/git/decorators.py", "copies": "1", "size": "2966", "license": "mit", "hash": -2638062753596887000, "line_mean": 42.6176470588, "line_max": 121, "alpha_frac": 0.6581254214, "autogenerated": false, "ratio": 4.2371428571428575, "config_test": ...
from functools import wraps from django.contrib.auth.views import redirect_to_login from django.core.exceptions import ImproperlyConfigured from django.core.exceptions import PermissionDenied from django.shortcuts import get_object_or_404 from django.utils.decorators import available_attrs from sphinxdoc.models impor...
{ "repo_name": "kamni/django-sphinxdoc", "path": "sphinxdoc/decorators.py", "copies": "1", "size": "1100", "license": "mit", "hash": -5008816620252744000, "line_mean": 31.3529411765, "line_max": 75, "alpha_frac": 0.6954545455, "autogenerated": false, "ratio": 4.313725490196078, "config_test": fa...
from functools import wraps from django.contrib.contenttypes.models import ContentType def memoize(func, cache, num_args): """ Wrap a function so that results for any argument tuple are stored in 'cache'. Note that the args to the function must be usable as dictionary keys. Only the first num_ar...
{ "repo_name": "gradel/django-generic-bookmarks", "path": "bookmarks/utils.py", "copies": "1", "size": "1728", "license": "mit", "hash": -5686530245159022000, "line_mean": 28.7931034483, "line_max": 76, "alpha_frac": 0.6128472222, "autogenerated": false, "ratio": 3.4353876739562623, "config_test...
from functools import wraps from django.contrib import admin from django.shortcuts import render_to_response from .job import run_job from .models import Job, Artefact class ArtefactInline(admin.TabularInline): model = Artefact class JobAdmin(admin.ModelAdmin): class Meta: model = Job inlines...
{ "repo_name": "anentropic/django-director", "path": "director/admin.py", "copies": "1", "size": "1042", "license": "mit", "hash": -4289076413876069000, "line_mean": 21.170212766, "line_max": 74, "alpha_frac": 0.6247600768, "autogenerated": false, "ratio": 3.917293233082707, "config_test": false...
from functools import wraps from django.contrib import auth from django.contrib.auth.decorators import login_required from django.contrib.auth.models import User as djUser from django.core.urlresolvers import reverse from django.http.response import HttpResponseRedirect, JsonResponse from django.shortcuts import (get_...
{ "repo_name": "expfactory/expfactory-docker", "path": "expdj/apps/users/views.py", "copies": "2", "size": "3983", "license": "mit", "hash": 1413642146524776000, "line_mean": 34.8828828829, "line_max": 79, "alpha_frac": 0.6228973136, "autogenerated": false, "ratio": 4.28740581270183, "config_tes...
from functools import wraps from django.contrib import messages from django.contrib.auth import logout from django.contrib.auth.decorators import login_required from django.contrib.auth.models import User from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger from django.http import HttpResponseForbi...
{ "repo_name": "satdav/mozillians", "path": "apps/phonebook/views.py", "copies": "1", "size": "8300", "license": "bsd-3-clause", "hash": -3246758227456984000, "line_mean": 32.6032388664, "line_max": 79, "alpha_frac": 0.6422891566, "autogenerated": false, "ratio": 3.8658593386120166, "config_test...
from functools import wraps from django.contrib import messages from django.contrib.auth import REDIRECT_FIELD_NAME from django.contrib.auth.decorators import user_passes_test from django.contrib.auth.views import redirect_to_login from django.core.exceptions import PermissionDenied from django.core.urlresolvers impor...
{ "repo_name": "sonofatailor/django-oscar", "path": "src/oscar/views/decorators.py", "copies": "5", "size": "5064", "license": "bsd-3-clause", "hash": -6806849112219631000, "line_mean": 38.5625, "line_max": 79, "alpha_frac": 0.672985782, "autogenerated": false, "ratio": 4.298811544991511, "confi...
from functools import wraps from django.contrib import messages from django.shortcuts import redirect from django.template.response import TemplateResponse from django.utils.translation import pgettext from django.views.decorators.http import require_POST from ..core import load_checkout from ...discount.forms import...
{ "repo_name": "jreigel/saleor", "path": "saleor/checkout/views/discount.py", "copies": "7", "size": "2405", "license": "bsd-3-clause", "hash": -4040458176382093000, "line_mean": 34.8955223881, "line_max": 78, "alpha_frac": 0.6249480249, "autogenerated": false, "ratio": 4.572243346007604, "confi...
from functools import wraps from django.contrib import messages from django.shortcuts import redirect from django.utils.decorators import method_decorator from django.core.urlresolvers import reverse from django.http import HttpResponseRedirect from remo.base.utils import get_object_or_none from funfactory.helpers imp...
{ "repo_name": "chirilo/remo", "path": "remo/base/decorators.py", "copies": "3", "size": "4336", "license": "bsd-3-clause", "hash": 5188769711069400000, "line_mean": 38.7798165138, "line_max": 78, "alpha_frac": 0.6093173432, "autogenerated": false, "ratio": 4.479338842975206, "config_test": fals...
from functools import wraps from django.contrib import messages from django.shortcuts import redirect from confucius.models import Conference, Membership def role_required(test_func): def decorator(view_func): def inner_decorator(request, *args, **kwargs): pk = kwargs.pop('conference_pk', No...
{ "repo_name": "jfouca/confucius", "path": "confucius/decorators.py", "copies": "1", "size": "2112", "license": "bsd-3-clause", "hash": 1843415584846560500, "line_mean": 31.4923076923, "line_max": 93, "alpha_frac": 0.6325757576, "autogenerated": false, "ratio": 4.249496981891348, "config_test": ...
from functools import wraps from django.contrib import messages from django.utils.decorators import available_attrs from django.http import HttpResponseRedirect def user_passes_test(test_func, login_url=None, message=None): """ Decorator for views that checks that the user passes the given test, redirect...
{ "repo_name": "thoas/django-backward", "path": "backward/decorators.py", "copies": "1", "size": "1983", "license": "mit", "hash": 7565412773987969000, "line_mean": 31.5081967213, "line_max": 83, "alpha_frac": 0.5980837115, "autogenerated": false, "ratio": 4.527397260273973, "config_test": true,...
from functools import wraps from django.contrib.sites.models import get_current_site from django.core import urlresolvers from django.core.paginator import EmptyPage, PageNotAnInteger from django.http import Http404 from django.template.response import TemplateResponse from django.utils import six def x_robots_tag(fu...
{ "repo_name": "makinacorpus/django", "path": "django/contrib/sitemaps/views.py", "copies": "1", "size": "2512", "license": "bsd-3-clause", "hash": 9186603623373989000, "line_mean": 35.9411764706, "line_max": 77, "alpha_frac": 0.6234076433, "autogenerated": false, "ratio": 3.955905511811024, "co...
from functools import wraps from django.contrib.sites.models import Site from django.core.exceptions import ImproperlyConfigured from django.utils.module_loading import import_string from filer.settings import FILER_ROLES_MANAGER def get_roles_manager(): if hasattr(get_roles_manager, '_cache'): return g...
{ "repo_name": "pbs/django-filer", "path": "filer/utils/cms_roles.py", "copies": "1", "size": "2863", "license": "bsd-3-clause", "hash": 7633846157807199000, "line_mean": 29.1368421053, "line_max": 87, "alpha_frac": 0.6496681802, "autogenerated": false, "ratio": 3.583229036295369, "config_test":...
from functools import wraps from django.core.cache import cache from django.http import HttpResponseBadRequest from django.core.exceptions import ObjectDoesNotExist def get_cache_key(prefix, *args, **kwargs): """ Calculates cache key based on `args` and `kwargs`. `args` and `kwargs` must be instances of ...
{ "repo_name": "steelkiwi/django-skd-tools", "path": "skd_tools/decorators.py", "copies": "1", "size": "3012", "license": "mit", "hash": 1083305489574984200, "line_mean": 32.0989010989, "line_max": 88, "alpha_frac": 0.6075697211, "autogenerated": false, "ratio": 4.3652173913043475, "config_test"...
from functools import wraps from django.core.cache import cache from django.utils.safestring import mark_safe from django.utils.translation import ugettext as _ from django.core.exceptions import ValidationError from django.contrib.formtools.preview import FormPreview try: from django.db.transaction import atomic...
{ "repo_name": "armstrong/armstrong.apps.embeds", "path": "armstrong/apps/embeds/admin_forms.py", "copies": "1", "size": "11104", "license": "apache-2.0", "hash": -220776903057456060, "line_mean": 40.5880149813, "line_max": 109, "alpha_frac": 0.6206772334, "autogenerated": false, "ratio": 4.272412...
from functools import wraps from django.core.checks import Error from minicash.core.settings import minicash_settings class NotDefined: pass def is_defined(name): return getattr(minicash_settings, name, NotDefined) != NotDefined class requires_minicash_settings: '''A decorator which checks for requi...
{ "repo_name": "BasicWolf/minicash", "path": "src/minicash/utils/checks.py", "copies": "1", "size": "1386", "license": "apache-2.0", "hash": 2701488773807183000, "line_mean": 29.8, "line_max": 72, "alpha_frac": 0.5707070707, "autogenerated": false, "ratio": 4.37223974763407, "config_test": false...
from functools import wraps from django.core.exceptions import ImproperlyConfigured, PermissionDenied from django.shortcuts import get_object_or_404 from django.conf import settings OWNERSHIP_REQUIRED_PASS_OBJ = getattr(settings, 'OWNERSHIP_REQUIRED_PASS_OBJ', True) OWNERSHIP_REQUIRED_CALLABLE = getattr(settings, 'O...
{ "repo_name": "arturtamborski/wypok", "path": "wypok/wypok/utils/ownership_required.py", "copies": "1", "size": "1978", "license": "mit", "hash": 3452480315233919500, "line_mean": 34.9636363636, "line_max": 99, "alpha_frac": 0.6450960566, "autogenerated": false, "ratio": 4.012170385395538, "con...
from functools import wraps from django.core.exceptions import ObjectDoesNotExist from django.http import Http404, HttpResponseRedirect from django.shortcuts import render_to_response, get_object_or_404 from django.template import RequestContext from apps.public_api.util import (public_api_method, short_id, long_id) ...
{ "repo_name": "canvasnetworks/canvas", "path": "website/apps/public_api/views.py", "copies": "1", "size": "4488", "license": "bsd-3-clause", "hash": 5399292817061321000, "line_mean": 32.2444444444, "line_max": 207, "alpha_frac": 0.6586452763, "autogenerated": false, "ratio": 3.899218071242398, ...
from functools import wraps from django.core.exceptions import PermissionDenied from django.contrib.auth.views import redirect_to_login from django.utils.decorators import available_attrs from mc2.organizations.models import Organization, ORGANIZATION_SESSION_KEY def active_organization(request): ''' Return...
{ "repo_name": "praekelt/mc2", "path": "mc2/organizations/utils.py", "copies": "1", "size": "2493", "license": "bsd-2-clause", "hash": -5707773765753588000, "line_mean": 34.1126760563, "line_max": 77, "alpha_frac": 0.6662655435, "autogenerated": false, "ratio": 4.475763016157989, "config_test": ...
from functools import wraps from django.core.exceptions import PermissionDenied from django.contrib.auth.views import redirect_to_login from django.utils.decorators import available_attrs from organizations.models import Organization, ORGANIZATION_SESSION_KEY def active_organization(request): ''' Returns th...
{ "repo_name": "universalcore/unicore-mc", "path": "organizations/utils.py", "copies": "1", "size": "2360", "license": "bsd-2-clause", "hash": -2336069458586184700, "line_mean": 33.7058823529, "line_max": 77, "alpha_frac": 0.6661016949, "autogenerated": false, "ratio": 4.521072796934866, "config...
from functools import wraps from django.core.exceptions import PermissionDenied from django.http import Http404 from django.shortcuts import redirect from django.contrib.auth.decorators import user_passes_test from helpdesk import settings as helpdesk_settings def check_staff_status(check_staff=False): """ ...
{ "repo_name": "rossp/django-helpdesk", "path": "helpdesk/decorators.py", "copies": "3", "size": "3226", "license": "bsd-3-clause", "hash": -5593637674583856000, "line_mean": 34.8444444444, "line_max": 105, "alpha_frac": 0.6946683199, "autogenerated": false, "ratio": 3.8588516746411483, "config_...
from functools import wraps from django.core.exceptions import PermissionDenied from django.views.decorators.csrf import csrf_exempt from canvas import util, knobs, browse from canvas.api_decorators import json_service from canvas.exceptions import ServiceError from canvas.metrics import Metrics from canvas.redis_mod...
{ "repo_name": "canvasnetworks/canvas", "path": "website/apps/public_api/util.py", "copies": "1", "size": "1688", "license": "bsd-3-clause", "hash": -2442527364042362400, "line_mean": 29.1428571429, "line_max": 107, "alpha_frac": 0.634478673, "autogenerated": false, "ratio": 4.009501187648456, "...
from functools import wraps from django.core import mail from django.test.utils import override_settings from mock import MagicMock, patch import requests_mock import pytest from fjord.base.tests import TestCase from fjord.mailinglist.models import MailingList from fjord.translations import gengo_utils from fjord.tr...
{ "repo_name": "mozilla/fjord", "path": "fjord/translations/tests/test_gengo.py", "copies": "2", "size": "28033", "license": "bsd-3-clause", "hash": 1131356856437822200, "line_mean": 34.5297845374, "line_max": 79, "alpha_frac": 0.5030856491, "autogenerated": false, "ratio": 3.8522742888552974, "...
from functools import wraps from django.core.urlresolvers import reverse from django.http import HttpResponseRedirect, HttpResponseServerError from django.utils.importlib import import_module from social_auth.backends import get_backend from social_auth.utils import setting, log, backend_setting LOGIN_ERROR_URL = s...
{ "repo_name": "kurdd/Oauth", "path": "social_auth/decorators.py", "copies": "1", "size": "2339", "license": "apache-2.0", "hash": 183984425909346780, "line_mean": 37.9833333333, "line_max": 79, "alpha_frac": 0.5472424113, "autogenerated": false, "ratio": 5.129385964912281, "config_test": false,...
from functools import wraps from django.core.urlresolvers import reverse from django.http import HttpResponseRedirect from mtvc_client.client import APIClientException def view_exception_handler(view_func): """ A view decorator that undestands MTVC error codes and how to deal with the state changes that...
{ "repo_name": "praekelt/mtvc-api-client", "path": "mtvc_client/libs/django/decorators.py", "copies": "1", "size": "1422", "license": "mit", "hash": -4816038160615530000, "line_mean": 32.0697674419, "line_max": 77, "alpha_frac": 0.6610407876, "autogenerated": false, "ratio": 4.572347266881029, "...
from functools import wraps from django.core.urlresolvers import reverse from django.shortcuts import render from django.contrib.auth.views import (password_reset, password_reset_confirm, password_reset_done, ...
{ "repo_name": "kyokley/MediaViewer", "path": "mediaviewer/views/password_reset.py", "copies": "1", "size": "3900", "license": "mit", "hash": -4676138099855332000, "line_mean": 34.7798165138, "line_max": 79, "alpha_frac": 0.5902564103, "autogenerated": false, "ratio": 4.572098475967175, "config_...
from functools import wraps from django.core.urlresolvers import reverse from django.views.decorators.http import require_POST from django.views.decorators.csrf import csrf_protect from social_auth.backends import get_backend from social_auth.exceptions import WrongBackend from social_auth.utils import setting def ...
{ "repo_name": "WW-Digital/django-social-auth", "path": "social_auth/decorators.py", "copies": "8", "size": "1438", "license": "bsd-3-clause", "hash": 5095708184951222000, "line_mean": 34.0731707317, "line_max": 78, "alpha_frac": 0.6550764951, "autogenerated": false, "ratio": 4.452012383900929, ...
from functools import wraps from django.db import connection from django.test import TestCase from django.conf import settings from django.contrib.auth.models import User, Group from django.contrib.contenttypes.models import ContentType from django.contrib.sites.models import Site from django.template.loader import Te...
{ "repo_name": "azizmb/django-activity-stream", "path": "actstream/tests.py", "copies": "1", "size": "13429", "license": "bsd-3-clause", "hash": 8410365819424353000, "line_mean": 39.4487951807, "line_max": 111, "alpha_frac": 0.607565716, "autogenerated": false, "ratio": 3.794574738626731, "confi...
from functools import wraps from django.db import models from django.contrib.contenttypes.models import ContentType _get_content_type_for_model_cache = {} def memoize(func, cache, num_args): """ Wrap a function so that results for any argument tuple are stored in 'cache'. Note that the args to the funct...
{ "repo_name": "gradel/django-generic-ratings", "path": "ratings/managers.py", "copies": "3", "size": "4301", "license": "mit", "hash": 5835416001931856000, "line_mean": 33.685483871, "line_max": 81, "alpha_frac": 0.5956754243, "autogenerated": false, "ratio": 4.019626168224299, "config_test": f...
from functools import wraps from django.db import ( connections, DEFAULT_DB_ALIAS, DatabaseError, Error, ProgrammingError) from django.utils.decorators import available_attrs class TransactionManagementError(ProgrammingError): """ This exception is thrown when transaction management is used improperl...
{ "repo_name": "aleksandra-tarkowska/django", "path": "django/db/transaction.py", "copies": "10", "size": "12081", "license": "bsd-3-clause", "hash": -557718563460745300, "line_mean": 37.474522293, "line_max": 80, "alpha_frac": 0.5901001573, "autogenerated": false, "ratio": 5.080319596299411, "c...
from functools import wraps from django.db import ( connections, DEFAULT_DB_ALIAS, DatabaseError, ProgrammingError) from django.utils.decorators import available_attrs class TransactionManagementError(ProgrammingError): """ This exception is thrown when transaction management is used improperly. ...
{ "repo_name": "simone/django-gb", "path": "django/db/transaction.py", "copies": "1", "size": "10779", "license": "bsd-3-clause", "hash": 2849975187987581400, "line_mean": 36.4270833333, "line_max": 80, "alpha_frac": 0.6096112812, "autogenerated": false, "ratio": 4.904003639672429, "config_test"...
from functools import wraps from django.db import transaction from django.core.files.base import ContentFile from django.core.cache import get_cache from .AgentManager import AgentManager from .ActivityManager import ActivityManager from ..models import Verb, Statement, StatementRef, StatementAttachment, StatementCon...
{ "repo_name": "daafgo/Server_LRS", "path": "lrs/objects/StatementManager.py", "copies": "1", "size": "13074", "license": "apache-2.0", "hash": 3550631034251883000, "line_mean": 41.3139158576, "line_max": 141, "alpha_frac": 0.5819183112, "autogenerated": false, "ratio": 4.523875432525951, "confi...
from functools import wraps from django.db.models import Manager from django.db.models.query import QuerySet from django.utils.six import with_metaclass def _make_proxy(name, fn): @wraps(fn) def _proxy(self, *args, **kwargs): qs = self.get_queryset() return getattr(qs, name)(*args, **kwargs) ...
{ "repo_name": "timheap/django-chainable-manager", "path": "chainablemanager/manager.py", "copies": "1", "size": "2019", "license": "unlicense", "hash": 1150073468862308700, "line_mean": 30.546875, "line_max": 76, "alpha_frac": 0.6567607727, "autogenerated": false, "ratio": 4.37012987012987, "co...
from functools import wraps from django.db.models import Max from tars.api.utils import str2bool, convert_status from tars.deployment.constants import HALTED, SUCCESS from tars.deployment.models import TarsDeployment, TarsFortDeployment def fort_batch(param='fort_batch'): def decorator(func): @wraps(fun...
{ "repo_name": "ctripcorp/tars", "path": "tars/api/decorators.py", "copies": "1", "size": "6578", "license": "apache-2.0", "hash": 3429720263150346000, "line_mean": 33.0829015544, "line_max": 93, "alpha_frac": 0.5717543326, "autogenerated": false, "ratio": 4.211267605633803, "config_test": false...
from functools import wraps from django.forms.models import construct_instance from foundry.forms import JoinForm from neo.models import NeoProfile def patch_join_clean(original_clean): @wraps(original_clean) def clean_join_form(form): cleaned_data = original_clean(form) if not form._error...
{ "repo_name": "praekelt/jmbo-neo", "path": "neo/forms.py", "copies": "1", "size": "1477", "license": "bsd-3-clause", "hash": 8561914426054323000, "line_mean": 28.54, "line_max": 87, "alpha_frac": 0.6702775897, "autogenerated": false, "ratio": 3.8363636363636364, "config_test": false, "has_no_...