text stringlengths 0 1.05M | meta dict |
|---|---|
from functools import wraps
from flask import session, flash, redirect, url_for
from app.models.SQL_DB import User
# Login required decorator
def login_required(f):
@wraps(f)
def wrap(*args, **kwargs):
if 'logged_in' in session:
return f(*args, **kwargs)
else:
flash('Y... | {
"repo_name": "Pytlicek/VOBS",
"path": "app/models/Checks.py",
"copies": "1",
"size": "1167",
"license": "mit",
"hash": 3532951732295303700,
"line_mean": 23.829787234,
"line_max": 62,
"alpha_frac": 0.5852613539,
"autogenerated": false,
"ratio": 4.052083333333333,
"config_test": false,
"has_no... |
from functools import wraps
from flask import session, redirect, url_for
from flask import abort
from passlib.hash import argon2
from orator.exceptions.query import QueryException
from onepage.models import User
from onepage.models import Novel
LOGGED_IN_IDENTIFIER = "logged_in"
def can_login(email, password):
... | {
"repo_name": "Subarunari/onepage",
"path": "onepage/utils/auth.py",
"copies": "1",
"size": "2477",
"license": "mit",
"hash": 5342001130475283000,
"line_mean": 23.77,
"line_max": 96,
"alpha_frac": 0.6685506661,
"autogenerated": false,
"ratio": 3.764437689969605,
"config_test": false,
"has_no_... |
from functools import wraps
from flask import url_for, request, render_template
from flask_login import current_user
from werkzeug.utils import redirect
def login_required(f):
@wraps(f)
def decorated_function(*args, **kwargs):
if current_user is None or current_user.is_authenticated() is False:
... | {
"repo_name": "mandrive/FlaskTest",
"path": "utils/utils.py",
"copies": "1",
"size": "1240",
"license": "mit",
"hash": 1129672658238032900,
"line_mean": 26.5555555556,
"line_max": 76,
"alpha_frac": 0.6056451613,
"autogenerated": false,
"ratio": 4.275862068965517,
"config_test": false,
"has_no... |
from functools import wraps
from flask_sqlalchemy import SQLAlchemy
from werkzeug.exceptions import BadRequest
import flask
import requests
from . import extractor
api = flask.Blueprint("api", __name__)
web = flask.Blueprint("web", __name__)
def create_app() -> flask.Flask:
app = flask.Flask(__name__)
ap... | {
"repo_name": "erik/sketches",
"path": "projects/recipebin-py/recipebin/web.py",
"copies": "1",
"size": "1271",
"license": "mit",
"hash": -5356633158840891000,
"line_mean": 21.6964285714,
"line_max": 70,
"alpha_frac": 0.6325727773,
"autogenerated": false,
"ratio": 3.684057971014493,
"config_tes... |
from functools import wraps
from funcy import decorator
@decorator
def rwlocked(call, read=None, write=None):
import sys
from dvc.rwlock import rwlock
from dvc.dependency.repo import RepoDependency
if read is None:
read = []
if write is None:
write = []
stage = call._args[0... | {
"repo_name": "dmpetrov/dataversioncontrol",
"path": "dvc/stage/decorators.py",
"copies": "1",
"size": "1187",
"license": "apache-2.0",
"hash": 1920991245414375700,
"line_mean": 22.2745098039,
"line_max": 74,
"alpha_frac": 0.5787700084,
"autogenerated": false,
"ratio": 3.9046052631578947,
"conf... |
from functools import wraps
from funcy import decorator
@decorator
def rwlocked(call, read=None, write=None):
import sys
from dvc.dependency.repo import RepoDependency
from dvc.rwlock import rwlock
if read is None:
read = []
if write is None:
write = []
stage = call._args[... | {
"repo_name": "efiop/dvc",
"path": "dvc/stage/decorators.py",
"copies": "1",
"size": "1518",
"license": "apache-2.0",
"hash": -795806231315422200,
"line_mean": 22.71875,
"line_max": 74,
"alpha_frac": 0.5803689065,
"autogenerated": false,
"ratio": 3.8823529411764706,
"config_test": false,
"has... |
from functools import wraps
from funk.error import FunkyError
from funk.call import Call
from funk.call import IntegerCallCount
from funk.call import InfiniteCallCount
from funk.sequence import Sequence
from funk.util import function_call_str
from . import pycompat
from .tools import data
__all__ = ['with_mocks', 'M... | {
"repo_name": "mwilliamson/funk",
"path": "funk/__init__.py",
"copies": "1",
"size": "6979",
"license": "bsd-2-clause",
"hash": -7579493514223519000,
"line_mean": 36.1223404255,
"line_max": 127,
"alpha_frac": 0.6033815733,
"autogenerated": false,
"ratio": 3.9675952245594086,
"config_test": fals... |
from functools import wraps
from fuzzysearch.common import FuzzySearchBase, Match
from fuzzysearch.compat import text_type, xrange
__all__ = [
'search_exact',
'ExactSearch',
]
CLASSES_WITH_INDEX = (list, tuple)
CLASSES_WITH_FIND = (bytes, bytearray, text_type)
try:
from Bio.Seq import Seq
except Impor... | {
"repo_name": "taleinat/fuzzysearch",
"path": "src/fuzzysearch/search_exact.py",
"copies": "1",
"size": "2662",
"license": "mit",
"hash": 8351028903281778000,
"line_mean": 30.3176470588,
"line_max": 96,
"alpha_frac": 0.6149511645,
"autogenerated": false,
"ratio": 4.021148036253776,
"config_test... |
from functools import wraps
from fuzzysearch.compat import int_types
from attr import attrs, attrib
__all__ = [
'Match', 'LevenshteinSearchParams',
'count_differences_with_maximum',
'group_matches', 'get_best_match_in_group',
'consolidate_overlapping_matches',
]
@attrs(frozen=True, slots=True)
cla... | {
"repo_name": "taleinat/fuzzysearch",
"path": "src/fuzzysearch/common.py",
"copies": "1",
"size": "7375",
"license": "mit",
"hash": 7443151393031251000,
"line_mean": 34.119047619,
"line_max": 82,
"alpha_frac": 0.5728813559,
"autogenerated": false,
"ratio": 4.159616469261139,
"config_test": fals... |
from functools import wraps
from gi.repository import Gtk
from ..application import input_alg, builder
from ..model.input import Condition, JumpTo, JumpFrom, Control, End, ControlBlock
from .util import get_handler_constructor
id_chooser = builder.get_object('id_chooser')
id_input = builder.get_object('id_input')
... | {
"repo_name": "uvNikita/fsm_builder",
"path": "fsm_builder/handlers/toolbar.py",
"copies": "1",
"size": "2141",
"license": "mit",
"hash": 8718089638182733000,
"line_mean": 21.5368421053,
"line_max": 81,
"alpha_frac": 0.6412891172,
"autogenerated": false,
"ratio": 3.3716535433070867,
"config_tes... |
from functools import wraps
from git_orm import transaction, GitError
from git_orm.sync import fetch, push, merge
from tiget.cmds import Cmd
__all__ = ['Begin', 'Commit', 'Rollback', 'Fetch', 'Push', 'Merge']
def catch_git_error(fn):
@wraps(fn)
def _inner(self, args):
try:
return fn(se... | {
"repo_name": "natano/tiget",
"path": "tiget/core/cmds/git.py",
"copies": "1",
"size": "1314",
"license": "isc",
"hash": -1089442359798031700,
"line_mean": 17.7714285714,
"line_max": 67,
"alpha_frac": 0.6225266362,
"autogenerated": false,
"ratio": 3.7223796033994336,
"config_test": false,
"ha... |
from functools import wraps
from git_orm import transaction
from tiget.cmds import Cmd
from tiget.table import Table
from tiget.scrum.models import Ticket, User
from tiget.utils import open_in_editor
def require_user(fn):
@wraps(fn)
def _inner(self, args):
try:
user = User.current()
... | {
"repo_name": "natano/tiget",
"path": "tiget/scrum/cmds.py",
"copies": "1",
"size": "2298",
"license": "isc",
"hash": -4731468286903679000,
"line_mean": 25.4137931034,
"line_max": 79,
"alpha_frac": 0.6040034813,
"autogenerated": false,
"ratio": 3.785831960461285,
"config_test": false,
"has_no... |
from functools import wraps
from google.appengine.ext import deferred
from mutex import Mutex
def merge(dict1, dict2):
data = {}
data.update(dict1)
data.update(dict2)
return data
class task(object):
"""
This decorator help to create delay task easily
Parameters could be:
_countdow... | {
"repo_name": "trustcircleglobal/tcg-gae",
"path": "tcg_gae/task.py",
"copies": "1",
"size": "2902",
"license": "isc",
"hash": -8318074710403391000,
"line_mean": 29.8723404255,
"line_max": 76,
"alpha_frac": 0.61130255,
"autogenerated": false,
"ratio": 3.749354005167959,
"config_test": false,
... |
from functools import wraps
from huey import RedisHuey
def _task_wrapper(task_fn, pre_task=None, post_task=None):
@wraps(task_fn)
def inner(*args, **kwargs):
if pre_task is not None:
pre_task()
result = task_fn(*args, **kwargs)
if post_task is not None:
post_ta... | {
"repo_name": "pombredanne/huey",
"path": "huey/wrapper.py",
"copies": "2",
"size": "1100",
"license": "mit",
"hash": 3708291903903587000,
"line_mean": 30.4285714286,
"line_max": 76,
"alpha_frac": 0.52,
"autogenerated": false,
"ratio": 3.900709219858156,
"config_test": false,
"has_no_keywords... |
from functools import wraps
from . import compat
from .base import make_key_func, get_serializer, get_expire
from .wrappers import load_wrappers
class make_cache(object):
def __init__(self, cache, ttl=600, fmt='msgpack', fuzzy_ttl=True):
self.cache = cache
self.ttl = ttl
self.fmt = fmt
... | {
"repo_name": "baverman/cachel",
"path": "cachel/simple.py",
"copies": "1",
"size": "1226",
"license": "mit",
"hash": 7638278697207634000,
"line_mean": 36.1515151515,
"line_max": 74,
"alpha_frac": 0.5970636215,
"autogenerated": false,
"ratio": 3.7378048780487805,
"config_test": false,
"has_no... |
from functools import wraps
from . import filters
from .asyncsupport import auto_aiter
from .asyncsupport import auto_await
async def auto_to_seq(value):
seq = []
if hasattr(value, "__aiter__"):
async for item in value:
seq.append(item)
else:
for item in value:
seq... | {
"repo_name": "mitsuhiko/jinja2",
"path": "src/jinja2/asyncfilters.py",
"copies": "3",
"size": "4246",
"license": "bsd-3-clause",
"hash": -1670468177936462800,
"line_mean": 26.0445859873,
"line_max": 86,
"alpha_frac": 0.6594441828,
"autogenerated": false,
"ratio": 3.5442404006677797,
"config_te... |
from functools import wraps
from .inspect import get_full_arg_spec
class typed(object):
""" Decorator that does type checks according to annotations.
@typed(strict=True)
def do_something(a: bool, b: int = 3) -> bool:
return False
"""
def __init__(self, annotations=None, strict=False):
... | {
"repo_name": "snogaraleal/adjax",
"path": "adjax/utils/types.py",
"copies": "1",
"size": "1888",
"license": "mit",
"hash": -7832632849146310000,
"line_mean": 28.9682539683,
"line_max": 74,
"alpha_frac": 0.530720339,
"autogenerated": false,
"ratio": 4.684863523573201,
"config_test": false,
"h... |
from functools import wraps
from jinja2.asyncsupport import auto_aiter
from jinja2 import filters
async def auto_to_seq(value):
seq = []
if hasattr(value, '__aiter__'):
async for item in value:
seq.append(item)
else:
for item in value:
seq.append(item)
return s... | {
"repo_name": "cdgallahue/atomic-turbine",
"path": "web/lib/python2.7/site-packages/jinja2/asyncfilters.py",
"copies": "217",
"size": "4144",
"license": "mit",
"hash": 6862721363820964000,
"line_mean": 27.3835616438,
"line_max": 76,
"alpha_frac": 0.6493725869,
"autogenerated": false,
"ratio": 3.5... |
from functools import wraps
from markupsafe import Markup
from jinja2 import Environment
from jinja2.compiler import CodeGenerator
class LocalOverridingCodeGenerator(CodeGenerator):
def visit_Template(self, *args, **kwargs):
super(LocalOverridingCodeGenerator, self).visit_Template(*args,
... | {
"repo_name": "mbr/jinja-vanish",
"path": "jinja_vanish/__init__.py",
"copies": "1",
"size": "2222",
"license": "mit",
"hash": -2521852490328145400,
"line_mean": 33.1846153846,
"line_max": 76,
"alpha_frac": 0.6098109811,
"autogenerated": false,
"ratio": 4.452905811623246,
"config_test": false,
... |
from functools import wraps
from ming.orm import ThreadLocalORMSession
from allura.model.project import Project, Neighborhood, AppConfig
from allura.model.auth import User
from allura.model.discuss import Discussion, Thread, Post
def flush_on_return(fn):
@wraps(fn)
def new_fn(*args, **kwargs):
resul... | {
"repo_name": "leotrubach/sourceforge-allura",
"path": "Allura/allura/tests/unit/factories.py",
"copies": "1",
"size": "1642",
"license": "apache-2.0",
"hash": -7667391126739619000,
"line_mean": 23.1470588235,
"line_max": 74,
"alpha_frac": 0.652862363,
"autogenerated": false,
"ratio": 3.657015590... |
from functools import wraps
from modbus_tk.modbus import ModbusError
from pyjsonrpc.rpcerror import jsonrpcerrors, JsonRpcError
modbus_mapping = {}
def json_rpc_error(func):
""" Wraps a function and raises a JSON RPC error when a ModbusError has
been excepted::
@json_rpc_error()
def modbus_... | {
"repo_name": "AdvancedClimateSystems/Tolk",
"path": "tolk/exceptions.py",
"copies": "1",
"size": "3348",
"license": "mpl-2.0",
"hash": 3001984135148082000,
"line_mean": 26.2195121951,
"line_max": 91,
"alpha_frac": 0.7168458781,
"autogenerated": false,
"ratio": 3.8794901506373116,
"config_test"... |
from functools import wraps
from neupy.network import errors
from neupy.utils import format_data
__all__ = ('mse', 'rmse', 'mae', 'msle', 'rmsle', 'binary_crossentropy',
'categorical_crossentropy')
def override_theano_function(function):
""" Override theano function and help evaluate output result.
... | {
"repo_name": "stczhc/neupy",
"path": "neupy/estimators.py",
"copies": "1",
"size": "1260",
"license": "mit",
"hash": 6673941216718866000,
"line_mean": 28.3023255814,
"line_max": 74,
"alpha_frac": 0.6936507937,
"autogenerated": false,
"ratio": 3.925233644859813,
"config_test": false,
"has_no_... |
from functools import wraps
from nose import SkipTest
class Capabilities(dict):
def __missing__(self, capability):
probe = getattr(self, '_' + capability)
self[capability] = have = probe()
return have
def _genshi(self):
try:
from genshi.template import MarkupTemp... | {
"repo_name": "mmerickel/flatland",
"path": "tests/markup/_util.py",
"copies": "2",
"size": "5322",
"license": "mit",
"hash": 2685856432010759000,
"line_mean": 26.8638743455,
"line_max": 74,
"alpha_frac": 0.5415257422,
"autogenerated": false,
"ratio": 4.464765100671141,
"config_test": true,
"... |
from functools import wraps
from oauthlib.oauth2 import Server
from django.http import HttpResponseForbidden
from django.core.exceptions import ImproperlyConfigured
from .oauth2_validators import OAuth2Validator
from .oauth2_backends import OAuthLibCore
from .scopes import get_scopes_backend
from .settings import oau... | {
"repo_name": "DeskConnect/django-oauth-toolkit",
"path": "oauth2_provider/decorators.py",
"copies": "2",
"size": "3117",
"license": "bsd-2-clause",
"hash": -8441618289534767000,
"line_mean": 36.1071428571,
"line_max": 94,
"alpha_frac": 0.6191851139,
"autogenerated": false,
"ratio": 4.52394775036... |
from functools import wraps
from osgeo import ogr
import shapely.wkb
from geoalchemy.base import WKBSpatialElement, WKTSpatialElement
def reproject_from_native_spatial_reference(f):
@wraps(f)
def within(self, boundary, spatial_reference=None, **kwargs):
# Find the native spatial reference
nat... | {
"repo_name": "rjw57/foldbeam",
"path": "foldbeam/rendering/geometry.py",
"copies": "1",
"size": "2623",
"license": "apache-2.0",
"hash": -5073183530063551000,
"line_mean": 35.9436619718,
"line_max": 127,
"alpha_frac": 0.6599313763,
"autogenerated": false,
"ratio": 3.9325337331334334,
"config_t... |
from functools import wraps
from os import getenv
from sqlalchemy.orm import sessionmaker
from cafe.abc.compat import abstractclassmethod
from cafe.patterns.context import SessionManager
class SQLAlchemySessionManager(SessionManager):
ENGINE = None
@classmethod
def default(cls):
return cls.ins... | {
"repo_name": "betsybookwyrm/python-cafe-sqlalchemy",
"path": "cafe/database/sqlalchemy/session.py",
"copies": "1",
"size": "3849",
"license": "apache-2.0",
"hash": 5195884849008478000,
"line_mean": 30.2926829268,
"line_max": 102,
"alpha_frac": 0.6180826189,
"autogenerated": false,
"ratio": 4.609... |
from functools import wraps
from pipetools.debug import repr_args, set_name, get_name
from pipetools.ds_builder import DSBuilder, NoBuilder
from pipetools.main import pipe, XObject, StringFormatter, xcurry
def pipe_util(func):
"""
Decorator that handles X objects and currying for pipe-utils.
"""
@wra... | {
"repo_name": "starenka/pipetools",
"path": "pipetools/decorators.py",
"copies": "1",
"size": "1638",
"license": "mit",
"hash": 1170350596101668900,
"line_mean": 26.7627118644,
"line_max": 78,
"alpha_frac": 0.6440781441,
"autogenerated": false,
"ratio": 4.084788029925187,
"config_test": false,
... |
from functools import wraps
from plash import utils
from plash.eval import hint, register_macro
def cache_container_hint(cache_key_templ):
def decorator(func):
@wraps(func)
def wrapper(*args):
cache_key = cache_key_templ.format(":".join(args)).replace("/", "%")
container_i... | {
"repo_name": "ihucos/plash",
"path": "lib/python/plash/macros/froms.py",
"copies": "1",
"size": "1917",
"license": "mit",
"hash": -5020219556562920000,
"line_mean": 24.2236842105,
"line_max": 80,
"alpha_frac": 0.6478873239,
"autogenerated": false,
"ratio": 3.4854545454545454,
"config_test": fa... |
from functools import wraps
from plumeria.command import CommandError
async def get_voice_client(member, move_to=False, any_channel=False):
user_voice_channel = member.voice.voice_channel
if user_voice_channel is None:
raise CommandError("You are not currently in a voice channel.")
voice_client =... | {
"repo_name": "sk89q/Plumeria",
"path": "plumeria/util/voice.py",
"copies": "1",
"size": "1178",
"license": "mit",
"hash": -4633650814688203000,
"line_mean": 33.6470588235,
"line_max": 97,
"alpha_frac": 0.6748726655,
"autogenerated": false,
"ratio": 3.993220338983051,
"config_test": false,
"h... |
from functools import wraps
from pubsub import pub
__author__ = 'e.kolpakov'
def get_observers(target):
"""
Gets observer attached to callable, if any
:param target: callable
:return: BaseObserver
"""
raw = getattr(target, BaseObserver.OBSERVER_ATTRIBUTE) if hasattr(target, BaseObserver.OBS... | {
"repo_name": "e-kolpakov/study-model",
"path": "model/infrastructure/observers.py",
"copies": "1",
"size": "4693",
"license": "mit",
"hash": 8154139428601111000,
"line_mean": 27.9691358025,
"line_max": 118,
"alpha_frac": 0.6119752823,
"autogenerated": false,
"ratio": 4.301558203483043,
"config... |
from functools import wraps
from pulsar.api import ImproperlyConfigured
from pulsar.apps import wsgi
from lux.models import Schema
from lux.openapi import OperationInfo
from lux.utils.data import compact_dict
class route(wsgi.route):
"""Extend pulsar wsgi route decorator for openapi information
It adds the... | {
"repo_name": "quantmind/lux",
"path": "lux/ext/rest/route.py",
"copies": "1",
"size": "1874",
"license": "bsd-3-clause",
"hash": 6896493764760453000,
"line_mean": 32.4642857143,
"line_max": 77,
"alpha_frac": 0.5789754536,
"autogenerated": false,
"ratio": 4.696741854636591,
"config_test": false... |
from functools import wraps
from pyaib.components import component_class
@component_class("acl")
class ACL(object):
def __init__(self, ctx, config):
self.permissions = config.get("permissions", {})
def allowed(self, trigger, chan, nick):
channel = self.permissions.get(chan, {})
cmd =... | {
"repo_name": "gchandrasa/pinbot",
"path": "pinbot/components/acl.py",
"copies": "1",
"size": "1171",
"license": "mit",
"hash": -8604532056675650000,
"line_mean": 29.8157894737,
"line_max": 67,
"alpha_frac": 0.6037574722,
"autogenerated": false,
"ratio": 3.9163879598662206,
"config_test": false... |
from functools import wraps
from pycloudia.utils.defer import inline_callbacks, return_value, maybe_deferred
from pycloudia.cluster.consts import HEADER, STATUS
from pycloudia.cluster.interfaces import IRequestPackage
__all__ = [
'ResolverMeta',
'resolve_errors',
'resolve_method',
]
class ResolverMeta(... | {
"repo_name": "cordis/pycloudia",
"path": "pycloudia/cluster/resolver.py",
"copies": "1",
"size": "2525",
"license": "mit",
"hash": 1927005801108601000,
"line_mean": 30.5625,
"line_max": 88,
"alpha_frac": 0.5952475248,
"autogenerated": false,
"ratio": 4.484902309058614,
"config_test": false,
... |
from functools import wraps
from pyramid.httpexceptions import HTTPNotFound, HTTPForbidden
from social.utils import setting_name, module_member
from social.strategies.utils import get_strategy
from social.backends.utils import user_backends_data
DEFAULTS = {
'STORAGE': 'social.apps.pyramid_app.models.PyramidSto... | {
"repo_name": "imsparsh/python-social-auth",
"path": "social/apps/pyramid_app/utils.py",
"copies": "3",
"size": "2264",
"license": "bsd-3-clause",
"hash": -1389448066563892200,
"line_mean": 32.7910447761,
"line_max": 79,
"alpha_frac": 0.6347173145,
"autogenerated": false,
"ratio": 4.2003710575139... |
from functools import wraps
from qtpy import QtWidgets
from .histogram import HistogramWidget, HistogramModel, HistogramController
from .pdsspect_image_set import PDSSpectImageSetViewBase
class BasicHistogramModel(HistogramModel):
"""Model for the hhistograms in the Basic Widgets
Attributes
---------
... | {
"repo_name": "planetarypy/pdsspect",
"path": "pdsspect/basic.py",
"copies": "1",
"size": "10353",
"license": "bsd-3-clause",
"hash": -2988340413348178400,
"line_mean": 30.2779456193,
"line_max": 78,
"alpha_frac": 0.6127692456,
"autogenerated": false,
"ratio": 4.176280758370311,
"config_test": ... |
from functools import wraps
from redis import Redis, StrictRedis
from rq import Queue
import ujson
from search.whoosh_redis_storage import RedisStore
redis_conn = StrictRedis()
# no args implies the default queue
q = Queue(connection=redis_conn)
########## decorator stuff ############
from django.http import... | {
"repo_name": "zhy0216/random-read",
"path": "utils/__init__.py",
"copies": "1",
"size": "2075",
"license": "mit",
"hash": 741807323389888000,
"line_mean": 25.2658227848,
"line_max": 84,
"alpha_frac": 0.593253012,
"autogenerated": false,
"ratio": 4.029126213592233,
"config_test": false,
"has_... |
from functools import wraps
from rest_framework.generics import GenericAPIView
from rest_framework.renderers import JSONRenderer
from c3nav.mapdata.utils.json import json_encoder_reindent
default_app_config = 'c3nav.api.apps.APIConfig'
orig_render = JSONRenderer.render
@wraps(JSONRenderer.render)
def nicer_rende... | {
"repo_name": "c3nav/c3nav",
"path": "src/c3nav/api/__init__.py",
"copies": "1",
"size": "1335",
"license": "apache-2.0",
"hash": -1247203535589538300,
"line_mean": 35.0810810811,
"line_max": 111,
"alpha_frac": 0.7018726592,
"autogenerated": false,
"ratio": 3.75,
"config_test": false,
"has_no... |
from functools import wraps
from rest_framework import status as status_code
from rest_framework.response import Response
from app.models import Passphrase
def guard(func):
"""
This decorator enforces passphrase authentication.
"""
@wraps(func)
def decorated_func(viewset, request, pk=None, *arg... | {
"repo_name": "waitress-andela/waitress",
"path": "waitress/app/decorators.py",
"copies": "2",
"size": "1032",
"license": "mit",
"hash": -3265002032095217700,
"line_mean": 31.25,
"line_max": 90,
"alpha_frac": 0.628875969,
"autogenerated": false,
"ratio": 4.467532467532467,
"config_test": false,... |
from functools import wraps
from rest_framework import status
from rest_framework.response import Response
def params(**kwargs):
"""
Request fn decorator that builds up a list of params and automatically returns a 400 if they are invalid.
The validated params are passed to the wrapped function as... | {
"repo_name": "pombredanne/django-rest-params",
"path": "django_rest_params/__init__.py",
"copies": "3",
"size": "8989",
"license": "bsd-3-clause",
"hash": 7914815665428855000,
"line_mean": 38.7743362832,
"line_max": 149,
"alpha_frac": 0.4815886083,
"autogenerated": false,
"ratio": 4.667185877466... |
from functools import wraps
from reversion.compat import is_authenticated
from reversion.revisions import create_revision as create_revision_base, set_user, get_user
class _RollBackRevisionView(Exception):
def __init__(self, response):
self.response = response
def _request_creates_revision(request):
... | {
"repo_name": "htwenhe/DJOA",
"path": "env/Lib/site-packages/reversion/views.py",
"copies": "1",
"size": "2217",
"license": "mit",
"hash": -3771546092535379000,
"line_mean": 31.6029411765,
"line_max": 107,
"alpha_frac": 0.6143437077,
"autogenerated": false,
"ratio": 4.407554671968191,
"config_t... |
from functools import wraps
from rumble import rumble
fib_timer = rumble.Rumble()
for x in [3, 9, 17]:
fib_timer.arguments(x)
def memoize(f):
'''memoizer for single-argument functions'''
_cache = {}
@wraps(f)
def wrapper(x):
try:
return _cache[x]
except KeyError:
... | {
"repo_name": "mambocab/rumble",
"path": "examples/classexample.py",
"copies": "1",
"size": "1541",
"license": "mit",
"hash": 4564701663443459000,
"line_mean": 20.7042253521,
"line_max": 65,
"alpha_frac": 0.545100584,
"autogenerated": false,
"ratio": 3.0215686274509803,
"config_test": false,
... |
from functools import wraps
from six import string_types
from .queue import Queue
from .worker import PQ_DEFAULT_RESULT_TTL
class job(object):
def __init__(self, queue, connection='default', timeout=None,
result_ttl=PQ_DEFAULT_RESULT_TTL):
"""A decorator that adds a ``delay`` method to the d... | {
"repo_name": "bretth/django-pq",
"path": "pq/decorators.py",
"copies": "1",
"size": "1299",
"license": "bsd-2-clause",
"hash": -1185458996288759300,
"line_mean": 33.2105263158,
"line_max": 81,
"alpha_frac": 0.5935334873,
"autogenerated": false,
"ratio": 4.163461538461538,
"config_test": false,... |
from functools import wraps
from slackminion.plugin import cmd
from slackminion.plugin.base import BasePlugin
from . import version
try:
from . import commit
except ImportError:
commit = 'HEAD'
def user_mgt_command(f):
@wraps(f)
def wrapper(self, msg, args):
if len(args) < 2:
ret... | {
"repo_name": "arcticfoxnv/slackminion",
"path": "slackminion/plugins/core/acl.py",
"copies": "1",
"size": "6225",
"license": "mit",
"hash": -4281970976525875000,
"line_mean": 28.9278846154,
"line_max": 115,
"alpha_frac": 0.546184739,
"autogenerated": false,
"ratio": 3.718637992831541,
"config_... |
from functools import wraps
from statsmodels.tools.data import _is_using_pandas
from statsmodels.tsa.base import datetools
from statsmodels.tsa.tsatools import freq_to_period
def _get_pandas_wrapper(X, trim_head=None, trim_tail=None, names=None):
index = X.index
#TODO: allow use index labels
if trim_head... | {
"repo_name": "wzbozon/statsmodels",
"path": "statsmodels/tsa/filters/_utils.py",
"copies": "29",
"size": "4391",
"license": "bsd-3-clause",
"hash": -3401104899099645400,
"line_mean": 28.4697986577,
"line_max": 77,
"alpha_frac": 0.5991801412,
"autogenerated": false,
"ratio": 3.5757328990228014,
... |
from functools import wraps
from statsmodels.tools.data import _is_using_pandas
from statsmodels.tsa.tsatools import freq_to_period
def _get_pandas_wrapper(X, trim_head=None, trim_tail=None, names=None):
index = X.index
#TODO: allow use index labels
if trim_head is None and trim_tail is None:
ind... | {
"repo_name": "bert9bert/statsmodels",
"path": "statsmodels/tsa/filters/_utils.py",
"copies": "2",
"size": "4348",
"license": "bsd-3-clause",
"hash": 8369541900056123000,
"line_mean": 28.3783783784,
"line_max": 77,
"alpha_frac": 0.5965961362,
"autogenerated": false,
"ratio": 3.575657894736842,
... |
from functools import wraps
from sympy.core import S, Symbol, sympify, Tuple, Integer, Basic, Expr
from sympy.core.decorators import call_highest_priority
from sympy.core.sympify import SympifyError
from sympy.functions import transpose, conjugate, adjoint
from sympy.matrices import ShapeError
from sympy.simplify impo... | {
"repo_name": "amitjamadagni/sympy",
"path": "sympy/matrices/expressions/matexpr.py",
"copies": "2",
"size": "11863",
"license": "bsd-3-clause",
"hash": -1735233517140174000,
"line_mean": 25.3037694013,
"line_max": 78,
"alpha_frac": 0.5755711034,
"autogenerated": false,
"ratio": 3.959612817089452... |
from functools import wraps
from sympy import Mul, symbols, lambdify, Add, LC, fraction
from sympy.printing.lambdarepr import NumPyPrinter
from sympy.printing.precedence import precedence
import numpy as np
import scipy.sparse.linalg
from .cram import CRAM_exp, get_CRAM_from_cache
from .partialfrac import (thetas_a... | {
"repo_name": "ergs/transmutagen",
"path": "transmutagen/codegen.py",
"copies": "1",
"size": "12068",
"license": "bsd-3-clause",
"hash": -5349966175652853000,
"line_mean": 32.9943661972,
"line_max": 119,
"alpha_frac": 0.5786377196,
"autogenerated": false,
"ratio": 3.654754694124773,
"config_tes... |
from functools import wraps
from twilio.twiml.voice_response import VoiceResponse
from twilio.twiml.messaging_response import MessagingResponse
from twilio.request_validator import RequestValidator
from flask import (
Flask,
abort,
current_app,
request,
)
import os
app = Flask(__name__)
def valid... | {
"repo_name": "TwilioDevEd/webhooks-example-flask",
"path": "app.py",
"copies": "1",
"size": "2164",
"license": "mit",
"hash": 7742135546815484000,
"line_mean": 26.05,
"line_max": 78,
"alpha_frac": 0.6538817006,
"autogenerated": false,
"ratio": 3.7898423817863396,
"config_test": false,
"has_n... |
from functools import wraps
from twisted.internet.defer import gatherResults
from twisted.web.client import getPage
from rhumba import RhumbaPlugin, cron
def unpack_args(fn):
return wraps(fn)(lambda self, args: fn(self, **args))
class Plugin(RhumbaPlugin):
"""
A plugin to periodically push an applicat... | {
"repo_name": "praekeltfoundation/seed-xylem",
"path": "seed/xylem/marathon_sync.py",
"copies": "1",
"size": "1937",
"license": "mit",
"hash": -642943967402458500,
"line_mean": 29.265625,
"line_max": 79,
"alpha_frac": 0.5952503872,
"autogenerated": false,
"ratio": 3.515426497277677,
"config_tes... |
from functools import wraps
from twisted.internet.defer import (
inlineCallbacks, returnValue, gatherResults, maybeDeferred)
from twisted.trial.unittest import SkipTest
from vumi.tests.helpers import VumiTestCase, PersistenceHelper
from zope.interface.verify import verifyObject
from go_store_service.collections i... | {
"repo_name": "praekelt/go-store-service",
"path": "go_store_service/collections/tests/test_collections.py",
"copies": "1",
"size": "18337",
"license": "bsd-3-clause",
"hash": 659917996073299000,
"line_mean": 34.6058252427,
"line_max": 79,
"alpha_frac": 0.6152587664,
"autogenerated": false,
"rati... |
from functools import wraps
from typing import Callable
from drf_openapi.entities import VersionedSerializers
from rest_framework.response import Response
def view_config(request_serializer=None, response_serializer=None, validate_response=False):
def decorator(view_method):
view_method.request_seriali... | {
"repo_name": "limdauto/drf_openapi",
"path": "drf_openapi/utils.py",
"copies": "1",
"size": "1565",
"license": "mit",
"hash": -3837737249476905500,
"line_mean": 40.1842105263,
"line_max": 93,
"alpha_frac": 0.6862619808,
"autogenerated": false,
"ratio": 4.905956112852665,
"config_test": false,
... |
from functools import wraps
from .utils import partial_prepare
def partial(func):
"""Wraps func to behave like a partial pipeline step, any output
that's not None or {} will be considered a response object and
will be returned to user.
The pipeline function will receive a current_partial object, it
... | {
"repo_name": "LennonChin/Django-Practices",
"path": "MxShop/extra_apps/social_core/pipeline/partial.py",
"copies": "4",
"size": "1400",
"license": "apache-2.0",
"hash": -7580702082072917000,
"line_mean": 35.8421052632,
"line_max": 76,
"alpha_frac": 0.6342857143,
"autogenerated": false,
"ratio": ... |
from functools import wraps
from .utils import smart_decorator, combine_alternatives
from .tree import Tree
from .exceptions import VisitError, GrammarError
from .lexer import Token
###{standalone
from inspect import getmembers, getmro
class Discard(Exception):
"""When raising the Discard exception in a transfo... | {
"repo_name": "erezsh/lark",
"path": "lark/visitors.py",
"copies": "1",
"size": "15756",
"license": "mit",
"hash": 3204314142606212600,
"line_mean": 32.2405063291,
"line_max": 133,
"alpha_frac": 0.6188753491,
"autogenerated": false,
"ratio": 4.3214481623697205,
"config_test": false,
"has_no_k... |
from functools import wraps
from .utils import thread_get_logger, get_func_path
from .exceptions import LoggerNotRegistered
def logexpose(logger_alias, func_before=None, func_after=None, level='debug'):
def wrapper(func):
@wraps(func)
def faked(*args, **kwargs):
logger = thread_get_l... | {
"repo_name": "idlesign/django-logexpose",
"path": "logexpose/decorators.py",
"copies": "1",
"size": "1573",
"license": "bsd-3-clause",
"hash": 3221982536553603000,
"line_mean": 31.7708333333,
"line_max": 115,
"alpha_frac": 0.5238397966,
"autogenerated": false,
"ratio": 4.172413793103448,
"conf... |
from functools import wraps
from vial import ref, refs
def test_ref():
refs.clear()
def boo(foo):
return foo
r = ref(boo)
assert r(1) == 1
assert str(r) == 'vial.refs[\'tests.test_ref.boo:10\']'
def test_ref_with_same_name():
refs.clear()
def boo():
return 1
r1 = ... | {
"repo_name": "guilhermedallanol/dotfiles",
"path": "vim/plugged/vial/tests/test_ref.py",
"copies": "2",
"size": "1210",
"license": "mit",
"hash": 2947145706250485000,
"line_mean": 15.5753424658,
"line_max": 64,
"alpha_frac": 0.5198347107,
"autogenerated": false,
"ratio": 3.025,
"config_test": ... |
from functools import wraps
from vumi.blinkenlights.metrics import Metric
from go.dashboard import client
from go.vumitools.metrics import (
get_account_metric_prefix, get_conversation_metric_prefix)
def is_collection(obj):
return (
isinstance(obj, dict)
or isinstance(obj, list)
or i... | {
"repo_name": "praekelt/vumi-go",
"path": "go/dashboard/dashboard.py",
"copies": "1",
"size": "5297",
"license": "bsd-3-clause",
"hash": 6421130393598828000,
"line_mean": 28.2651933702,
"line_max": 79,
"alpha_frac": 0.61657542,
"autogenerated": false,
"ratio": 4.093508500772797,
"config_test": ... |
from functools import wraps
from waffle.compat import CLASS_TYPES
from waffle.models import Flag, Switch, Sample
__all__ = ['override_flag', 'override_sample', 'override_switch']
class _overrider(object):
def __init__(self, name, active):
self.name = name
self.active = active
def __call__(... | {
"repo_name": "styleseat/django-waffle",
"path": "waffle/testutils.py",
"copies": "4",
"size": "3532",
"license": "bsd-3-clause",
"hash": -3124368710993069000,
"line_mean": 24.9705882353,
"line_max": 79,
"alpha_frac": 0.5784258211,
"autogenerated": false,
"ratio": 3.9819616685456594,
"config_te... |
from functools import wraps
from waffle.models import Flag, Switch, Sample
__all__ = ['override_flag', 'override_sample', 'override_switch']
class _overrider(object):
def __init__(self, name, active):
self.name = name
self.active = active
def __call__(self, func):
@wraps(func)
... | {
"repo_name": "safarijv/django-waffle",
"path": "waffle/testutils.py",
"copies": "5",
"size": "2804",
"license": "bsd-3-clause",
"hash": -3958064031515929600,
"line_mean": 24.4909090909,
"line_max": 79,
"alpha_frac": 0.5866619116,
"autogenerated": false,
"ratio": 3.8622589531680442,
"config_tes... |
from functools import wraps
from waffle.models import Flag, Switch, Sample, uncache_flag
__all__ = ['override_flag', 'override_sample', 'override_switch']
class _overrider(object):
def __init__(self, name, active):
self.name = name
self.active = active
def __call__(self, func):
@wr... | {
"repo_name": "festicket/django-waffle",
"path": "waffle/testutils.py",
"copies": "1",
"size": "2780",
"license": "bsd-3-clause",
"hash": 1779226623963759900,
"line_mean": 23.3859649123,
"line_max": 79,
"alpha_frac": 0.5751798561,
"autogenerated": false,
"ratio": 3.921015514809591,
"config_test... |
from functools import wraps
from wedo.distance import interpolate_distance_data
from wedo.motor import processMotorValues
from wedo.tilt import process_tilt
from wedo.tilt import FLAT, TILT_BACK, TILT_FORWARD, TILT_LEFT, TILT_RIGHT
import os
import usb.core
import logging
logger = logging.getLogger('wedo')
ID_VENDO... | {
"repo_name": "nvazquez/Turtlebots",
"path": "plugins/wedo_plugin/wedo/__init__.py",
"copies": "1",
"size": "6290",
"license": "mit",
"hash": -3639753260016241700,
"line_mean": 30.608040201,
"line_max": 132,
"alpha_frac": 0.5910969793,
"autogenerated": false,
"ratio": 3.8660110633066993,
"confi... |
from functools import wraps
from werkzeug.exceptions import HTTPException
from werkzeug.routing import Map, Rule
from flask import current_app, request
from flask_socketio import join_room, leave_room
from .exc import InvalidRequestError, InvalidURIError, SocketAPIError
class SocketAPI(object):
def __init__(s... | {
"repo_name": "kyouko-taiga/Flask-SocketAPI",
"path": "flask_socketapi/socketapi.py",
"copies": "1",
"size": "7830",
"license": "mit",
"hash": 918672835432936700,
"line_mean": 35.4186046512,
"line_max": 89,
"alpha_frac": 0.5481481481,
"autogenerated": false,
"ratio": 4.7111913357400725,
"config... |
from functools import wraps
import anyjson
from tornado.web import RequestHandler, HTTPError
from celery import states
from celery.task.control import revoke
from celery.events.state import state
def JSON(fun):
@wraps(fun)
def _write_json(self, *args, **kwargs):
content = fun(self, *args, **kwargs... | {
"repo_name": "frac/celerymon",
"path": "celerymonitor/handlers/api.py",
"copies": "1",
"size": "2441",
"license": "bsd-3-clause",
"hash": 2991873580055679500,
"line_mean": 22.2476190476,
"line_max": 71,
"alpha_frac": 0.6374436706,
"autogenerated": false,
"ratio": 3.418767507002801,
"config_tes... |
from functools import wraps
import asyncio
try:
from aiomeasures import StatsD
except ImportError:
StatsD = None
from alamo_common.conf import AlamoSettings
from alamo_common import stats
settings = AlamoSettings()
_aiostatsd = None
def setup():
global _aiostatsd
host = 'udp://{}:{}'.format(setting... | {
"repo_name": "RulersOfAsgard/alamo-common",
"path": "alamo_common/aiostats.py",
"copies": "1",
"size": "3978",
"license": "apache-2.0",
"hash": 2276079599042615600,
"line_mean": 26.625,
"line_max": 72,
"alpha_frac": 0.5643539467,
"autogenerated": false,
"ratio": 3.8734177215189876,
"config_tes... |
from functools import wraps
import asyncpg
from .transactionmanager import ConnectionTransactionContextManager
from .connection import SAConnection as _SAConnection
@wraps(asyncpg.create_pool)
def create_pool(*args,
dialect=None,
connection_class=_SAConnection,
**conn... | {
"repo_name": "CanopyTax/asyncpgsa",
"path": "asyncpgsa/pool.py",
"copies": "1",
"size": "1049",
"license": "apache-2.0",
"hash": 6315420214096158000,
"line_mean": 32.8387096774,
"line_max": 74,
"alpha_frac": 0.6663489037,
"autogenerated": false,
"ratio": 4.281632653061225,
"config_test": false... |
from functools import wraps
import brewer2mpl
import numpy as np
import matplotlib as mpl
from matplotlib import cm
# Get Set2 from ColorBrewer, a set of colors deemed colorblind-safe and
# pleasant to look at by Drs. Cynthia Brewer and Mark Harrower of Pennsylvania
# State University. These colors look lovely toge... | {
"repo_name": "olgabot/prettyplotlib",
"path": "prettyplotlib/colors.py",
"copies": "1",
"size": "2394",
"license": "mit",
"hash": -6659177050495764000,
"line_mean": 30.5,
"line_max": 83,
"alpha_frac": 0.6766917293,
"autogenerated": false,
"ratio": 3.1541501976284585,
"config_test": false,
"h... |
from functools import wraps
import bugsnag
import sendgrid
from . import app, meetup_oauth, sendgrid_api
from flask import render_template, redirect, url_for, request, session, flash
from flask.ext.login import current_user, login_required, login_user, logout_user
from .forms import (VenueEditForm, VenueClaimForm, R... | {
"repo_name": "NYCPython/wheretomeetup",
"path": "meetups/views.py",
"copies": "1",
"size": "10073",
"license": "bsd-3-clause",
"hash": 4135505931576620000,
"line_mean": 30.478125,
"line_max": 115,
"alpha_frac": 0.6436017075,
"autogenerated": false,
"ratio": 3.405341446923597,
"config_test": fa... |
from functools import wraps
import cantal
from cantal_tools.metrics import appflow
requests = cantal.RequestTracker('requests')
post = cantal.RequestTracker('post')
appflow.ensure_branches('redis')
appflow.ensure_branches('mongo')
def request_tracking_middleware(wsgi_app):
def middleware(environ, start_respons... | {
"repo_name": "uvNikita/appstats",
"path": "appstats/metrics.py",
"copies": "1",
"size": "1666",
"license": "mit",
"hash": -1003079101688768300,
"line_mean": 29.2909090909,
"line_max": 60,
"alpha_frac": 0.6704681873,
"autogenerated": false,
"ratio": 3.976133651551313,
"config_test": false,
"h... |
from functools import wraps
import django
from django.core.management import get_commands, load_command_class
try:
from importlib import import_module
except ImportError:
from django.utils.importlib import import_module
from kronos.settings import PROJECT_MODULE, KRONOS_PYTHON, KRONOS_MANAGE, \
KRONOS_PY... | {
"repo_name": "jeanbaptistelab/django-kronos",
"path": "kronos/__init__.py",
"copies": "1",
"size": "5982",
"license": "mit",
"hash": 8002084115886691000,
"line_mean": 30.4842105263,
"line_max": 89,
"alpha_frac": 0.5222333668,
"autogenerated": false,
"ratio": 4.221594918842626,
"config_test": f... |
from functools import wraps
import django
try:
from django.db.models.expressions import BaseExpression, F
except ImportError:
# Django < 1.8
from django.db.models.expressions import ExpressionNode as BaseExpression, F
from django.db.models.sql.query import Query
from djmoney.models.fields import MoneyField... | {
"repo_name": "tsouvarev/django-money",
"path": "djmoney/models/managers.py",
"copies": "3",
"size": "7147",
"license": "bsd-3-clause",
"hash": -7054097099821306000,
"line_mean": 33.1961722488,
"line_max": 108,
"alpha_frac": 0.5929760739,
"autogenerated": false,
"ratio": 4.0355731225296445,
"co... |
from functools import wraps
import facebook
from django.contrib.auth import REDIRECT_FIELD_NAME
from django.http import (HttpResponse,
HttpResponseRedirect,
HttpResponseBadRequest)
from django.utils.decorators import available_attrs
from django.utils.http import urlquo... | {
"repo_name": "pythonforfacebook/django-facebook",
"path": "django_facebook/decorators.py",
"copies": "1",
"size": "3854",
"license": "mit",
"hash": -8149058800410113000,
"line_mean": 36.4174757282,
"line_max": 78,
"alpha_frac": 0.5492994292,
"autogenerated": false,
"ratio": 4.841708542713568,
... |
from functools import wraps
import flask_marshmallow
from flask_restplus import Namespace as OriginalNamespace
from flask_restplus.utils import merge
from webargs.flaskparser import use_args as use_webargs
from werkzeug import exceptions as http_exceptions
from .model import Model, DefaultHTTPErrorSchema
class Name... | {
"repo_name": "ssls/beetle-agent",
"path": "flask_restplus_patched/namespace.py",
"copies": "1",
"size": "6025",
"license": "mit",
"hash": -8273283527665469000,
"line_mean": 37.3757961783,
"line_max": 97,
"alpha_frac": 0.5346058091,
"autogenerated": false,
"ratio": 4.663312693498452,
"config_te... |
from functools import wraps
import flask
from flask import request, render_template
from . import ex_blueprint
"""
The default_session is only used for testing purposes
Alternative: 11010001 34563456
"""
DEFAULT_SESSION = '11010001'
ZEEGUU_LOGIN = 'https://www.zeeguu.unibe.ch/login?next='
ZEEGUU_SESSION = 'sessionID'... | {
"repo_name": "martinavagyan/zeeguu-exercises",
"path": "src/zeeguu_exercises/endpoints.py",
"copies": "1",
"size": "1414",
"license": "mit",
"hash": 4641035168417418000,
"line_mean": 23.3793103448,
"line_max": 67,
"alpha_frac": 0.6605374823,
"autogenerated": false,
"ratio": 3.672727272727273,
... |
from functools import wraps
import flask
import flask_marshmallow
from flask_restplus import Namespace as OriginalNamespace
from flask_restplus.utils import merge
from webargs.flaskparser import parser as webargs_parser
from werkzeug import cached_property, exceptions as http_exceptions
from ._http import HTTPStatus
... | {
"repo_name": "millen1m/flask-restplus-server-example",
"path": "flask_restplus_patched/namespace.py",
"copies": "1",
"size": "7715",
"license": "mit",
"hash": -2895260732488225300,
"line_mean": 38.1624365482,
"line_max": 96,
"alpha_frac": 0.5507453014,
"autogenerated": false,
"ratio": 4.66163141... |
from functools import wraps
import flask
import flask_marshmallow
from flask_restplus import Namespace as OriginalNamespace
from flask_restplus.utils import merge, unpack
from flask_restplus._http import HTTPStatus
from webargs.flaskparser import parser as webargs_parser
from werkzeug import cached_property, exception... | {
"repo_name": "frol/flask-restplus-server-example",
"path": "flask_restplus_patched/namespace.py",
"copies": "1",
"size": "8353",
"license": "mit",
"hash": -3171248025667173400,
"line_mean": 37.6712962963,
"line_max": 98,
"alpha_frac": 0.549383455,
"autogenerated": false,
"ratio": 4.6534818941504... |
from functools import wraps
import flask
import flask_marshmallow
from flask_restplus import Namespace as OriginalNamespace
from flask_restplus.utils import merge, unpack
from webargs.flaskparser import parser as webargs_parser
from werkzeug import cached_property, exceptions as http_exceptions
from ._http import HTT... | {
"repo_name": "Jaza/flask-restplus-patched",
"path": "flask_restplus_patched/namespace.py",
"copies": "1",
"size": "8339",
"license": "mit",
"hash": -644933325552082600,
"line_mean": 37.6064814815,
"line_max": 98,
"alpha_frac": 0.5487468521,
"autogenerated": false,
"ratio": 4.656058068118369,
"... |
from functools import wraps
import flask
import flask_socketio
import plotly
from plotly.graph_objs import Scatter, Layout
from .. import controllers, exceptions, models, signals
from . import forms
app = flask.Flask(__name__)
socketio = flask_socketio.SocketIO(app)
try:
app.config.from_pyfile('flask.cfg')
exc... | {
"repo_name": "Vayel/wello",
"path": "wello/ui/__init__.py",
"copies": "1",
"size": "6589",
"license": "mit",
"hash": 8454873397944438000,
"line_mean": 27.1367521368,
"line_max": 101,
"alpha_frac": 0.5855103281,
"autogenerated": false,
"ratio": 3.4965480616038236,
"config_test": true,
"has_no... |
from functools import wraps
import flask
def response(*, mimetype: str = None, template_file: str = None):
def response_inner(f):
# print("Wrapping in response {}".format(f.__name__), flush=True)
@wraps(f)
def view_method(*args, **kwargs):
response_val = f(*args, **kwargs)
... | {
"repo_name": "Wintellect/WintellectWebinars",
"path": "2019-06-06-ten-tips-python-web-devs-kennedy/code/top_10_web_explore/ex07_viewmodels/pypi_vm/infrastructure/view_modifiers.py",
"copies": "4",
"size": "1630",
"license": "apache-2.0",
"hash": 8286179227360220000,
"line_mean": 29.7547169811,
"line_m... |
from functools import wraps
import fluent_comments
from fluent_comments import appsettings
from fluent_comments.moderation import FluentCommentsModerator
def override_appsettings(**settings):
"""
Temporary override the appsettings.
"""
def _dec(func):
@wraps(func)
def _inner(*args, **... | {
"repo_name": "django-fluent/django-fluent-comments",
"path": "fluent_comments/tests/utils.py",
"copies": "2",
"size": "1694",
"license": "apache-2.0",
"hash": 4950031768383177000,
"line_mean": 32.88,
"line_max": 100,
"alpha_frac": 0.6629279811,
"autogenerated": false,
"ratio": 3.6746203904555315... |
from functools import wraps
import l18n
from django.contrib.auth import get_user_model
from django.contrib.auth.views import redirect_to_login as auth_redirect_to_login
from django.core.exceptions import PermissionDenied
from django.db.models import Q
from django.shortcuts import redirect
from django.urls import reve... | {
"repo_name": "timorieber/wagtail",
"path": "wagtail/admin/auth.py",
"copies": "4",
"size": "5599",
"license": "bsd-3-clause",
"hash": -4885849116090201000,
"line_mean": 30.9942857143,
"line_max": 107,
"alpha_frac": 0.6720843008,
"autogenerated": false,
"ratio": 4.34031007751938,
"config_test":... |
from functools import wraps
import ldap3
from flask import request, g, Response
from .settings import SiteSettings
from urllib.parse import urlparse
config = SiteSettings()
def requires_auth(f):
@wraps(f)
def decorated(*args, **kwargs):
auth = request.authorization
if not auth or not authent... | {
"repo_name": "ishgroup/lightbook",
"path": "ldap_api/ldap_auth.py",
"copies": "1",
"size": "1914",
"license": "apache-2.0",
"hash": -1602288027925998600,
"line_mean": 28,
"line_max": 79,
"alpha_frac": 0.6347962382,
"autogenerated": false,
"ratio": 4.272321428571429,
"config_test": false,
"ha... |
from functools import wraps
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
class InProcessCache(object):
def __init__(self):
self.flush()
... | {
"repo_name": "canvasnetworks/canvas",
"path": "website/canvas/cache_patterns.py",
"copies": "1",
"size": "6806",
"license": "bsd-3-clause",
"hash": 1738385425596303400,
"line_mean": 31.1037735849,
"line_max": 114,
"alpha_frac": 0.5941816045,
"autogenerated": false,
"ratio": 3.970828471411902,
... |
from functools import wraps
import newrelic.agent
from django.http import Http404, HttpResponsePermanentRedirect
from waffle import flag_is_active, switch_is_active
from kuma.core.urlresolvers import reverse
from kuma.core.utils import urlparams
from .exceptions import ReadOnlyException
from .utils import locale_and... | {
"repo_name": "a2sheppy/kuma",
"path": "kuma/wiki/decorators.py",
"copies": "2",
"size": "3963",
"license": "mpl-2.0",
"hash": -2482687405412813000,
"line_mean": 34.0707964602,
"line_max": 87,
"alpha_frac": 0.6298258895,
"autogenerated": false,
"ratio": 4.35973597359736,
"config_test": false,
... |
from functools import wraps
import numpy as np
import networkx as nx
import vigra
import collections
from contextlib import contextmanager
from .box import Box
class BlockflowArray(np.ndarray):
def __new__(cls, shape, dtype=float, buffer=None, offset=0, strides=None, order=None, box=None):
obj = np.ndarr... | {
"repo_name": "stuarteberg/blockflow",
"path": "blockflow/blockflow.py",
"copies": "1",
"size": "15659",
"license": "mit",
"hash": 531534710664469900,
"line_mean": 39.3582474227,
"line_max": 137,
"alpha_frac": 0.61562041,
"autogenerated": false,
"ratio": 3.732777115613826,
"config_test": false,... |
from functools import wraps
import numpy as np
import tensorflow as tf
from neupy.utils.misc import as_tuple
from neupy.utils.processing import asfloat
__all__ = (
# Main tensorflow functions
'tensorflow_session', 'tensorflow_eval', 'create_variable',
'initialize_uninitialized_variables', 'function',
... | {
"repo_name": "itdxer/neupy",
"path": "neupy/utils/tf_utils.py",
"copies": "1",
"size": "8447",
"license": "mit",
"hash": 1218204837948436500,
"line_mean": 25.2329192547,
"line_max": 78,
"alpha_frac": 0.6295726293,
"autogenerated": false,
"ratio": 4.1983101391650095,
"config_test": false,
"ha... |
from functools import wraps
import numpy as np
from ..base import normalize_token
from .core import (
concatenate_lookup,
tensordot_lookup,
map_blocks,
asanyarray,
blockwise,
)
from .routines import _average
from ..utils import derived_from
@normalize_token.register(np.ma.masked_array)
def norma... | {
"repo_name": "blaze/dask",
"path": "dask/array/ma.py",
"copies": "3",
"size": "7376",
"license": "bsd-3-clause",
"hash": 3103686533373151000,
"line_mean": 27.2605363985,
"line_max": 82,
"alpha_frac": 0.6095444685,
"autogenerated": false,
"ratio": 3.0229508196721313,
"config_test": false,
"ha... |
from functools import wraps
import numpy as np
from imagepipe.raw_functions import f_3d_stack_2d_filter, f_2d_stack_2d_filter
from imagepipe.tools.helpers import safe_dir_create, PipeArgError, list_not_string
safe_dir_create('verification') # guarantees existence, although might not be the best location to do it
... | {
"repo_name": "chiffa/Image_pipe",
"path": "imagepipe/core_functions.py",
"copies": "1",
"size": "8930",
"license": "bsd-3-clause",
"hash": 7053279866917215000,
"line_mean": 37.3261802575,
"line_max": 135,
"alpha_frac": 0.5617021277,
"autogenerated": false,
"ratio": 4.270683883309421,
"config_t... |
from functools import wraps
import numpy as np
from menpo.image import BooleanImage, Image, MaskedImage
from menpo.transform import NonUniformScale, Translation
def lm_centres_correction(centres):
r"""
Construct a transform that will correct landmarks for a window
iterating feature calculation
Para... | {
"repo_name": "menpo/menpo",
"path": "menpo/feature/base.py",
"copies": "2",
"size": "4258",
"license": "bsd-3-clause",
"hash": -382021686838935550,
"line_mean": 31.7538461538,
"line_max": 78,
"alpha_frac": 0.6183654298,
"autogenerated": false,
"ratio": 3.805183199285076,
"config_test": false,
... |
from functools import wraps
import numpy as np
class LossFunction:
"""Defines a loss function that maps nonlinearity activations to error."""
def loss(self, activities, targets):
"""Computes the loss for each unit in the network.
Note that most loss functions are only based on the output of... | {
"repo_name": "drasmuss/hessianfree",
"path": "hessianfree/loss_funcs.py",
"copies": "1",
"size": "9402",
"license": "bsd-2-clause",
"hash": 5645156485957538000,
"line_mean": 34.2134831461,
"line_max": 78,
"alpha_frac": 0.6356094448,
"autogenerated": false,
"ratio": 4.0736568457538995,
"config_... |
from functools import wraps
import numpy as np
def stvariogram(func):
@wraps(func)
def wrapper(*args, **kwargs):
st = args[0]
if st.ndim == 2:
new_args = args[1:]
mapping = map(lambda lags: func(lags, *new_args, **kwargs), st)
return np.fromiter(mapping, dt... | {
"repo_name": "mmaelicke/scikit-gstat",
"path": "skgstat/stmodels.py",
"copies": "1",
"size": "6628",
"license": "mit",
"hash": -5588692340878507000,
"line_mean": 33.7015706806,
"line_max": 89,
"alpha_frac": 0.6332226916,
"autogenerated": false,
"ratio": 3.479265091863517,
"config_test": false,... |
from functools import wraps
import numpy
import pyximport.pyximport
def cython_on_demand(unsafe):
"""
Enables loading .pyx files from .py files (on-demand compilation).
With `unsafe` deactivates all Cython safety checks and compatibility
options (do not use without first testing that things work rel... | {
"repo_name": "wrwrwr/blackbox",
"path": "cython_init.py",
"copies": "1",
"size": "1236",
"license": "mit",
"hash": -8291881390323234000,
"line_mean": 32.4054054054,
"line_max": 73,
"alpha_frac": 0.6189320388,
"autogenerated": false,
"ratio": 4.106312292358804,
"config_test": false,
"has_no_k... |
from functools import wraps
import numpy
from theano import scalar as scal, Constant
from theano.gof import local_optimizer
from theano.tensor import (DimShuffle, get_scalar_constant_value,
NotScalarConstantError)
from .basic_ops import GpuFromHost, HostFromGpu, GpuAllocEmpty
from .elemwis... | {
"repo_name": "marcsans/cnn-physics-perception",
"path": "phy/lib/python2.7/site-packages/theano/sandbox/gpuarray/opt_util.py",
"copies": "4",
"size": "11455",
"license": "mit",
"hash": 316731549541652000,
"line_mean": 33.6072507553,
"line_max": 76,
"alpha_frac": 0.5874290703,
"autogenerated": fals... |
from functools import wraps
import pandas as pd
def plot_dispatch(f):
@wraps(f)
def wrapper(self, **kwargs):
return self(kind=f.__name__, **kwargs)
wrapper.__doc__ = """Used to mimic the `pandas Series plotting API <http://pandas.pydata.org/pandas-docs/stable/api.html#plotting>`_ for {} plots. S... | {
"repo_name": "jackmaney/pg-utils",
"path": "pg_utils/column/plot/__init__.py",
"copies": "1",
"size": "1330",
"license": "mit",
"hash": -8542165187824364000,
"line_mean": 24.5769230769,
"line_max": 341,
"alpha_frac": 0.6345864662,
"autogenerated": false,
"ratio": 3.614130434782609,
"config_tes... |
from functools import wraps
import pytest
from overloading import *
from overloading import OverloadingError
from test_overloading import *
@overload
@decorated(2)
@decorated(1)
def f(*args):
return ('default',)
@overload
@decorated(4)
@decorated(3)
def f(foo, bar:int):
return ('any', 'int')
@overload
@de... | {
"repo_name": "bintoro/overloading.py",
"path": "tests/_test_decorated.py",
"copies": "1",
"size": "1116",
"license": "mit",
"hash": 8121240559360376000,
"line_mean": 16.7142857143,
"line_max": 45,
"alpha_frac": 0.585125448,
"autogenerated": false,
"ratio": 2.8469387755102042,
"config_test": fa... |
from functools import wraps
import redis
from django.conf import settings
from django.http import HttpRequest
from redis_ratelimit.exceptions import RateLimited
from redis_ratelimit.utils import parse_rate, build_redis_key
def is_rate_limited(request, rate=None):
if not rate:
return False
count, se... | {
"repo_name": "r00m/django-redis-ratelimit",
"path": "redis_ratelimit/decorators.py",
"copies": "1",
"size": "1250",
"license": "mit",
"hash": 6006605941059408000,
"line_mean": 25.5957446809,
"line_max": 84,
"alpha_frac": 0.6168,
"autogenerated": false,
"ratio": 3.869969040247678,
"config_test"... |
from functools import wraps
import requests
from flask import current_app
def cronitor(task_name):
# check if task_name is in config
def decorator(func):
def ping_cronitor(command):
if not current_app.config['CRONITOR_ENABLED']:
return
task_slug = current_app.... | {
"repo_name": "alphagov/notifications-api",
"path": "app/cronitor.py",
"copies": "1",
"size": "1684",
"license": "mit",
"hash": 8590191269943882000,
"line_mean": 32.0196078431,
"line_max": 98,
"alpha_frac": 0.4958432304,
"autogenerated": false,
"ratio": 4.811428571428571,
"config_test": false,
... |
from functools import wraps
import spbu
from flask import g
from requests import ConnectTimeout, ReadTimeout
from app.constants import (
access_denied_answer, read_timeout_answer, connect_timeout_answer,
spbu_api_exception_answer
)
from tg_bot import bot
from tg_bot.keyboards import link_button
def access_d... | {
"repo_name": "EeOneDown/spbu4u",
"path": "telebot_login/help_decorators.py",
"copies": "1",
"size": "3318",
"license": "apache-2.0",
"hash": 545329940212179140,
"line_mean": 28.1052631579,
"line_max": 70,
"alpha_frac": 0.5599758891,
"autogenerated": false,
"ratio": 4.1320049813200495,
"config_... |
from functools import wraps
import string
import cycl
import math
import numpy as np
import logging
log = logging.getLogger(__name__)
def memoize(fct):
"""
This is a decorator which cache the result of a function based on the
given parameter.
"""
return_dict = {}
@wraps(fct)
def wrappe... | {
"repo_name": "jmercier/CyCL",
"path": "cycl/clmath.py",
"copies": "1",
"size": "7521",
"license": "mit",
"hash": 4434104664914002400,
"line_mean": 28.37890625,
"line_max": 134,
"alpha_frac": 0.5470017285,
"autogenerated": false,
"ratio": 3.496513249651325,
"config_test": false,
"has_no_keywo... |
from functools import wraps
import substitution as sub
from util import forgiving_join
# To do:
# - Fix substitution:
# - substituting a quantified variable
# - see comments in substitution.py
# - Think about whether I want to add Function functionality
# - Add XOR, NOR
class Variable(object):
... | {
"repo_name": "mpvharmelen/resolution",
"path": "sentence.py",
"copies": "1",
"size": "12080",
"license": "mit",
"hash": 6375510882264510000,
"line_mean": 28.0819277108,
"line_max": 79,
"alpha_frac": 0.5680669484,
"autogenerated": false,
"ratio": 4.225840336134453,
"config_test": false,
"has_... |
from functools import wraps
import tensorflow as tf
class MetaModule(type):
def __new__(cls, name, bases, local):
cls = type.__new__(cls, name, bases, local)
def store_init_args(fn):
@wraps(fn)
def store_init_args_wrapper(self, *args, **kwargs):
fn(self, *... | {
"repo_name": "atomistic-machine-learning/SchNet",
"path": "src/schnet/nn/layers/module.py",
"copies": "1",
"size": "3059",
"license": "mit",
"hash": -272365729057080930,
"line_mean": 31.2,
"line_max": 71,
"alpha_frac": 0.5580254985,
"autogenerated": false,
"ratio": 4.06781914893617,
"config_te... |
from functools import wraps
#
# LISP-style list (llist)
#
class _LNoneProto:
def __repr__(self):
return "LNone"
def __str__(self):
return "LNone"
LNone = _LNoneProto()
def cons(hd, tl):
'''
lisp-style pair cell
'''
return (hd, tl)
def list_to_llist(lst):
result = LNone
... | {
"repo_name": "Algy/tempy",
"path": "lisn/functional.py",
"copies": "1",
"size": "5243",
"license": "apache-2.0",
"hash": 5416273232249867000,
"line_mean": 22.40625,
"line_max": 117,
"alpha_frac": 0.5891665077,
"autogenerated": false,
"ratio": 3.426797385620915,
"config_test": false,
"has_no_... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.