text stringlengths 0 1.05M | meta dict |
|---|---|
from functools import wraps
import logging
from peewee import create_model_tables
from peewee import drop_model_tables
logger = logging.getLogger('peewee')
class test_database(object):
def __init__(self, db, models, create_tables=True, drop_tables=True,
fail_silently=False):
self.db = d... | {
"repo_name": "zhang625272514/peewee",
"path": "playhouse/test_utils.py",
"copies": "24",
"size": "2675",
"license": "mit",
"hash": -1213632178259833000,
"line_mean": 29.3977272727,
"line_max": 78,
"alpha_frac": 0.5914018692,
"autogenerated": false,
"ratio": 3.7570224719101124,
"config_test": f... |
from functools import wraps
import logging
import jwt
default_parse_fmt = "%d-%m-%Y %H:%M:%S"
def get_secret():
return 'sflkjsdjkfd'
def token_verify(token):
secret = get_secret()
try:
return jwt.decode(token, secret, algorithm='HS256')
except jwt.DecodeError:
return False
def lo... | {
"repo_name": "x10an14/overtime-calculator",
"path": "overtime_calculator/__init__.py",
"copies": "1",
"size": "1295",
"license": "mit",
"hash": -7032534723760607000,
"line_mean": 24.3921568627,
"line_max": 63,
"alpha_frac": 0.5853281853,
"autogenerated": false,
"ratio": 3.7,
"config_test": fal... |
from functools import wraps
import logging
logger = logging.getLogger('peewee')
class _QueryLogHandler(logging.Handler):
def __init__(self, *args, **kwargs):
self.queries = []
logging.Handler.__init__(self, *args, **kwargs)
def emit(self, record):
self.queries.append(record)
class... | {
"repo_name": "coleifer/peewee",
"path": "playhouse/test_utils.py",
"copies": "2",
"size": "1737",
"license": "mit",
"hash": -3265926478779265000,
"line_mean": 27.0161290323,
"line_max": 75,
"alpha_frac": 0.5785837651,
"autogenerated": false,
"ratio": 3.8092105263157894,
"config_test": false,
... |
from functools import wraps
import math
import types
from django.utils.encoding import force_unicode
from django.utils.translation import ugettext_lazy as _
LOGARITHMIC, LINEAR = 1, 2
def parse_tags(tagstring):
"""
Parses tag input, with multiple word input being activated and
delineated by commas and do... | {
"repo_name": "vosi/django-xtags",
"path": "xtags/utils.py",
"copies": "1",
"size": "7135",
"license": "bsd-3-clause",
"hash": 6918574786971700000,
"line_mean": 31.7293577982,
"line_max": 101,
"alpha_frac": 0.5920112123,
"autogenerated": false,
"ratio": 3.9771460423634335,
"config_test": false,... |
from functools import wraps
import math
from flask import Response, g, jsonify, request
from backend.app import app
from backend.model import Session, User
@app.errorhandler(Exception)
def handle_exception(ex):
app.logger.exception(ex)
return make_error_response('Internal server error', 500)
@app.before_r... | {
"repo_name": "ianunruh/flask-api-skeleton",
"path": "backend/routes/__init__.py",
"copies": "1",
"size": "3512",
"license": "mit",
"hash": -4963749487858540000,
"line_mean": 26.4375,
"line_max": 103,
"alpha_frac": 0.5731776765,
"autogenerated": false,
"ratio": 4.1562130177514796,
"config_test"... |
from functools import wraps
import multiprocessing
import numpy
import logging
import geodat.units
logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger(__name__)
try:
import pyferret
PYFERRET_INSTALLED = True
_IMPORT_PYFERRET_ERROR = None
except ImportError:
logger.warning("Failed to... | {
"repo_name": "kitchoi/geodat",
"path": "geodat/pyferret_func.py",
"copies": "1",
"size": "11096",
"license": "mit",
"hash": 8668421425789902000,
"line_mean": 36.110367893,
"line_max": 80,
"alpha_frac": 0.5852559481,
"autogenerated": false,
"ratio": 3.7844474761255116,
"config_test": false,
"... |
from functools import wraps
import NodeDefender
from NodeDefender.mqtt.message.report.sensor import info
def verify_sensor_and_class(func):
@wraps(func)
def wrapper(topic, payload):
if not NodeDefender.db.sensor.get(topic['mac_address'], topic['node']):
NodeDefender.db.sensor.create(topic['... | {
"repo_name": "CTSNE/NodeDefender",
"path": "NodeDefender/mqtt/message/report/sensor/__init__.py",
"copies": "1",
"size": "1139",
"license": "mit",
"hash": -6210535532792508000,
"line_mean": 41.1851851852,
"line_max": 81,
"alpha_frac": 0.5926251097,
"autogenerated": false,
"ratio": 4.156934306569... |
from functools import wraps
import numbers
import uuid
import six
from decent.error import Error, Invalid
## Helpers
def All(*validators):
"""
Combines all the given validator callables into one, running all the
validators in sequence on the given value.
"""
@wraps(All)
def built(value):
... | {
"repo_name": "veeti/decent",
"path": "decent/validators.py",
"copies": "1",
"size": "8820",
"license": "mit",
"hash": -7574167442853030000,
"line_mean": 26.1384615385,
"line_max": 134,
"alpha_frac": 0.5987528345,
"autogenerated": false,
"ratio": 4.323529411764706,
"config_test": false,
"has_... |
from functools import wraps
import numpy as np
import xarray as xr
def xarray_loop_vars_over_dim(vars_to_loop, loop_dim):
"""
A decorator to feed CML data with mutiple channels as xarray.DataArrays to CML processing functions
Parameters
----------
vars_to_loop: list of strings
List of the... | {
"repo_name": "pycomlink/pycomlink",
"path": "pycomlink/processing/xarray_wrapper.py",
"copies": "2",
"size": "3162",
"license": "bsd-3-clause",
"hash": 178416684743740800,
"line_mean": 39.5384615385,
"line_max": 103,
"alpha_frac": 0.541429475,
"autogenerated": false,
"ratio": 4.127937336814622,
... |
from functools import wraps
import operator as op
class TypeCheckError(TypeError):
pass
def type_assertion(cond, error, msg=''):
if not cond:
raise error(msg)
return True
def assert_type(*types, **kw):
"""
`*tps`: types that function should accept
keywords:
@ret_: return type t... | {
"repo_name": "d10genes/typecheck.py",
"path": "typechecker.py",
"copies": "1",
"size": "6018",
"license": "bsd-3-clause",
"hash": 4801108309648688000,
"line_mean": 30.5078534031,
"line_max": 111,
"alpha_frac": 0.5579926886,
"autogenerated": false,
"ratio": 3.5567375886524824,
"config_test": fa... |
from functools import wraps
import operator
def err(f):
@wraps(f)
def wrapper(*a,**kw):
try:
return f(*a,**kw)
except Exception as e:
return DotDict()
return wrapper
class DotDict(dict):
__getattr__ = dict.__getitem__
__setattr__ = dict.__setitem__
__del... | {
"repo_name": "futurice/google-apps-contacts-copier",
"path": "shared/dots.py",
"copies": "1",
"size": "1527",
"license": "bsd-3-clause",
"hash": -3392198599149352400,
"line_mean": 28.3653846154,
"line_max": 121,
"alpha_frac": 0.540929928,
"autogenerated": false,
"ratio": 3.592941176470588,
"co... |
from functools import wraps
import operator
def opsame(op):
""" checks for type mismatch between first and second argument"""
@wraps(op)
def checked(self, other):
if not isinstance(other, type(self)):
return NotImplemented
return op(self, other)
return checked
def get_o... | {
"repo_name": "wabu/pyadds",
"path": "pyadds/ops.py",
"copies": "1",
"size": "2460",
"license": "mit",
"hash": -2893495618175582700,
"line_mean": 21.7777777778,
"line_max": 78,
"alpha_frac": 0.5845528455,
"autogenerated": false,
"ratio": 4.183673469387755,
"config_test": false,
"has_no_keywor... |
from functools import wraps
import os, json
from flask import Flask, render_template, request, g, session, flash, \
redirect, url_for, abort, send_from_directory, request, Response
from flask.ext.openid import OpenID
from flask.ext.autoindex import AutoIndex
app = Flask(__name__)
app.secret_key = '\xa5\x10\xbfN3... | {
"repo_name": "baloo/sbt-repo-buildpack",
"path": "src/app/app.py",
"copies": "2",
"size": "2239",
"license": "mit",
"hash": -6654188274304083000,
"line_mean": 26.9875,
"line_max": 88,
"alpha_frac": 0.6400178651,
"autogenerated": false,
"ratio": 3.3417910447761194,
"config_test": false,
"has_... |
from functools import wraps
import os
from contextlib import contextmanager
import platform
from django.core.exceptions import ImproperlyConfigured
from django.utils.importlib import import_module
class DefaultedAttributes(object):
def __init__(self, underlying, defaults):
self.underlying = underlying
... | {
"repo_name": "yaniv-aknin/django-ajaxerrors",
"path": "ajaxerrors/utils.py",
"copies": "1",
"size": "1815",
"license": "mit",
"hash": 5499710926605902000,
"line_mean": 33.9038461538,
"line_max": 118,
"alpha_frac": 0.6429752066,
"autogenerated": false,
"ratio": 4.448529411764706,
"config_test":... |
from functools import wraps
import os
from moto.xray import xray_backends
import aws_xray_sdk.core
from aws_xray_sdk.core.context import Context as AWSContext
from aws_xray_sdk.core.emitters.udp_emitter import UDPEmitter
class MockEmitter(UDPEmitter):
"""
Replaces the code that sends UDP to local X-Ray daemon... | {
"repo_name": "Affirm/moto",
"path": "moto/xray/mock_client.py",
"copies": "8",
"size": "3225",
"license": "apache-2.0",
"hash": 1833060008155643100,
"line_mean": 37.8554216867,
"line_max": 125,
"alpha_frac": 0.6737984496,
"autogenerated": false,
"ratio": 3.5833333333333335,
"config_test": fals... |
from functools import wraps
import os
from os.path import dirname
from threading import Thread
from fabric.api import *
from flask import flash
from pbkdf2 import crypt
from vagrant import Vagrant
from MAdmin import db
from MAdmin.sql.ORM import Device
def hash_password(password):
return crypt(password)
def ... | {
"repo_name": "MattTuri/M-Admin",
"path": "MAdmin/utils/__init__.py",
"copies": "1",
"size": "1707",
"license": "mit",
"hash": -7899169037185777000,
"line_mean": 23.7391304348,
"line_max": 91,
"alpha_frac": 0.6672524897,
"autogenerated": false,
"ratio": 3.476578411405295,
"config_test": false,
... |
from functools import wraps
import os
from platform import system as _curos
import re
import subprocess
CUR_OS = _curos()
IS_WIN = CUR_OS in ['Windows', 'cli']
IS_NIX = (not IS_WIN) and any(
CUR_OS.startswith(i) for i in
['CYGWIN', 'MSYS', 'Linux', 'Darwin', 'SunOS',
'FreeBSD', 'NetBSD', 'OpenBSD'])
RE_ANS... | {
"repo_name": "olafhauk/mne-python",
"path": "mne/externals/tqdm/_tqdm/utils.py",
"copies": "14",
"size": "10090",
"license": "bsd-3-clause",
"hash": -7324371763762669000,
"line_mean": 28.2463768116,
"line_max": 78,
"alpha_frac": 0.5325074331,
"autogenerated": false,
"ratio": 4.280865507000424,
... |
from functools import wraps
import os
import logging
import shutil
log = logging.getLogger(__name__)
def restoring_chdir(fn):
# XXX:dc: This would be better off in a neutral module
@wraps(fn)
def decorator(*args, **kw):
try:
path = os.getcwd()
return fn(*args, **kw)
... | {
"repo_name": "raven47git/readthedocs.org",
"path": "readthedocs/doc_builder/base.py",
"copies": "1",
"size": "3646",
"license": "mit",
"hash": 4686593517819269000,
"line_mean": 30.4310344828,
"line_max": 101,
"alpha_frac": 0.5787164015,
"autogenerated": false,
"ratio": 4.0874439461883405,
"con... |
from functools import wraps
import os
import logging
import shutil
log = logging.getLogger(__name__)
def restoring_chdir(fn):
#XXX:dc: This would be better off in a neutral module
@wraps(fn)
def decorator(*args, **kw):
try:
path = os.getcwd()
return fn(*args, **kw)
... | {
"repo_name": "vincentbernat/readthedocs.org",
"path": "readthedocs/doc_builder/base.py",
"copies": "2",
"size": "1720",
"license": "mit",
"hash": 2842243231134400500,
"line_mean": 27.6666666667,
"line_max": 99,
"alpha_frac": 0.6040697674,
"autogenerated": false,
"ratio": 4.226044226044226,
"co... |
from functools import wraps
import os
import logging
log = logging.getLogger(__name__)
def restoring_chdir(fn):
#XXX:dc: This would be better off in a neutral module
@wraps(fn)
def decorator(*args, **kw):
try:
path = os.getcwd()
return fn(*args, **kw)
finally:
... | {
"repo_name": "ojii/readthedocs.org",
"path": "readthedocs/doc_builder/base.py",
"copies": "1",
"size": "2260",
"license": "mit",
"hash": -8554999937035007000,
"line_mean": 26.2289156627,
"line_max": 80,
"alpha_frac": 0.6066371681,
"autogenerated": false,
"ratio": 4.737945492662474,
"config_tes... |
from functools import wraps
import os
import logging
log = logging.getLogger(__name__)
def restoring_chdir(fn):
#XXX:dc: This would be better off in a neutral module
@wraps(fn)
def decorator(*args, **kw):
try:
path = os.getcwd()
return fn(*args, **kw)
finally:
... | {
"repo_name": "1suming/readthedocs.org",
"path": "readthedocs/doc_builder/base.py",
"copies": "3",
"size": "2261",
"license": "mit",
"hash": -3299602246900728300,
"line_mean": 25.6,
"line_max": 77,
"alpha_frac": 0.6063688633,
"autogenerated": false,
"ratio": 4.740041928721174,
"config_test": fa... |
from functools import wraps
import os
import pickle
import six
from .types import Command
DEVNULL = open(os.devnull, 'w')
def which(program):
"""Returns `program` path or `None`."""
def is_exe(fpath):
return os.path.isfile(fpath) and os.access(fpath, os.X_OK)
fpath, fname = os.path.split(progr... | {
"repo_name": "ytjiang/thefuck",
"path": "thefuck/utils.py",
"copies": "1",
"size": "1895",
"license": "mit",
"hash": -1633204491955198200,
"line_mean": 22.6875,
"line_max": 66,
"alpha_frac": 0.5646437995,
"autogenerated": false,
"ratio": 4.164835164835165,
"config_test": false,
"has_no_keywo... |
from functools import wraps
import os
import pkgutil
from threading import local
import warnings
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from django.utils.functional import cached_property
from django.utils.importlib import import_module
from django.utils.module_loading... | {
"repo_name": "eltonsantos/django",
"path": "django/db/utils.py",
"copies": "3",
"size": "8980",
"license": "bsd-3-clause",
"hash": 4267677708260966000,
"line_mean": 30.9572953737,
"line_max": 92,
"alpha_frac": 0.5668151448,
"autogenerated": false,
"ratio": 4.574630667345899,
"config_test": fal... |
from functools import wraps
import os
import random
from django.core.cache import cache
from . import settings
def partial(func, *parameters, **kparms):
@wraps(func)
def wrapped(*args, **kw):
kw.update(kparms)
return func(*(args + parameters), **kw)
return wrapped
def assets_dir(instan... | {
"repo_name": "ff0000/scarlet",
"path": "scarlet/assets/utils.py",
"copies": "1",
"size": "1235",
"license": "mit",
"hash": 1964094179717079600,
"line_mean": 22.75,
"line_max": 69,
"alpha_frac": 0.6315789474,
"autogenerated": false,
"ratio": 3.569364161849711,
"config_test": false,
"has_no_ke... |
from functools import wraps
import os
import re
import inspect
try:
import unittest.mock as mock
except ImportError:
import mock
norm_pattern = re.compile(r'[/|.]')
def patch_plugin_file(*patch_args, **patch_kwargs):
"""
Decorator used to search for in items:
"""
root, filename = os.path.spli... | {
"repo_name": "wongwill86/air-tasks",
"path": "tests/utils/mock_helpers.py",
"copies": "1",
"size": "1302",
"license": "mit",
"hash": 934084375931314800,
"line_mean": 30,
"line_max": 77,
"alpha_frac": 0.6044546851,
"autogenerated": false,
"ratio": 3.863501483679525,
"config_test": false,
"has... |
from functools import wraps
import os
import re
import sys
from unittest.case import _ExpectedFailure, _UnexpectedSuccess
import sublime
from unittesting import DeferrableTestCase, AWAIT_WORKER
from GitSavvy.tests.mockito import mock, unstub, verify, when
from GitSavvy.tests.parameterized import parameterized as p
i... | {
"repo_name": "divmain/GitSavvy",
"path": "tests/test_diff_view.py",
"copies": "1",
"size": "19220",
"license": "mit",
"hash": 1336568132340221700,
"line_mean": 26.7344877345,
"line_max": 94,
"alpha_frac": 0.5528616025,
"autogenerated": false,
"ratio": 3.155475291413561,
"config_test": true,
... |
from functools import wraps
import os
import sys
# make sure gevent-socketio is not installed, as it conflicts with
# python-socketio
gevent_socketio_found = True
try:
from socketio import socketio_manage # noqa: F401
except ImportError:
gevent_socketio_found = False
if gevent_socketio_found:
print('The g... | {
"repo_name": "miguelgrinberg/Flask-SocketIO",
"path": "src/flask_socketio/__init__.py",
"copies": "1",
"size": "48388",
"license": "mit",
"hash": 7480011070761966000,
"line_mean": 47.1472636816,
"line_max": 79,
"alpha_frac": 0.5740266182,
"autogenerated": false,
"ratio": 4.952712384851586,
"co... |
from functools import wraps
import os
import traceback
from main.models import ExperimentSampleToAlignment
def set_assembly_status(sample_alignment, status, force=False):
"""Sets assembly status field.
"""
sample_alignment = ExperimentSampleToAlignment.objects.get(
uid=sample_alignment.uid)
... | {
"repo_name": "churchlab/millstone",
"path": "genome_designer/genome_finish/celery_task_decorator.py",
"copies": "1",
"size": "2433",
"license": "mit",
"hash": 3155846193480020000,
"line_mean": 35.3134328358,
"line_max": 80,
"alpha_frac": 0.6259761611,
"autogenerated": false,
"ratio": 4.652007648... |
from functools import wraps
import os
import urlparse
import requests
from dropbox import Dropbox
from dropbox.oauth import DropboxOAuth2Flow
from flask import (
Flask,
make_response,
redirect,
render_template,
request,
session,
url_for
)
APP_KEY = os.environ['APP_KEY']
APP_SECRET = os.environ['APP_SECRET']
... | {
"repo_name": "rahulamlekar/revision-browser",
"path": "app.py",
"copies": "1",
"size": "2766",
"license": "apache-2.0",
"hash": -2670434578335101000,
"line_mean": 26.66,
"line_max": 111,
"alpha_frac": 0.6659436009,
"autogenerated": false,
"ratio": 3.3567961165048543,
"config_test": false,
"h... |
from functools import wraps
import os
from client import AuthDecorator, HttpClient
from flask import Flask, jsonify, request, g
from flask_pymongo import PyMongo
from auth import create_user, get_user_by_token, login_user
from errors import APIError
app = Flask(__name__)
mongo_uri = 'mongodb://{}:{}@ds259325.mlab.c... | {
"repo_name": "Zubdano/zql",
"path": "zql-backend/gateway/server.py",
"copies": "1",
"size": "3477",
"license": "mit",
"hash": -5760732088150885000,
"line_mean": 28.218487395,
"line_max": 102,
"alpha_frac": 0.6701179177,
"autogenerated": false,
"ratio": 3.6910828025477707,
"config_test": false,... |
from functools import wraps
import os
import cv2
import numpy as np
def img_show(img):
cv2.imshow('img', img)
cv2.waitKey(0)
cv2.destroyAllWindows()
def reshape_and_show(arr, w=20, h=20):
arr = arr.reshape(w, h).astype(np.uint8)
img_show(arr)
def log_call(f):
@wraps(f)
def wrapper(*ar... | {
"repo_name": "bbuhai/sudoku-solver",
"path": "sudoku_solver/util.py",
"copies": "1",
"size": "1359",
"license": "mit",
"hash": 1402844434833954300,
"line_mean": 20.5714285714,
"line_max": 74,
"alpha_frac": 0.5643855776,
"autogenerated": false,
"ratio": 2.867088607594937,
"config_test": false,
... |
from functools import wraps
import os
import numpy
from fuel.datasets import H5PYDataset
class MissingInputFiles(Exception):
"""Exception raised by a converter when input files are not found.
Parameters
----------
filenames : list
A list of filenames that were not found.
"""
def __... | {
"repo_name": "lamblin/fuel",
"path": "fuel/converters/base.py",
"copies": "2",
"size": "4206",
"license": "mit",
"hash": 6654838012265609000,
"line_mean": 36.2212389381,
"line_max": 77,
"alpha_frac": 0.6019971469,
"autogenerated": false,
"ratio": 4.168483647175421,
"config_test": false,
"has... |
from functools import wraps
import os
class Lock(object):
"""
Lock implementation. Can also be used as a context-manager or
decorator.
Unlike the redis-py lock implementation, this Lock does not
use a spin-loop when blocking to acquire the lock. Instead,
it performs a blocking pop on a list. ... | {
"repo_name": "johndlong/walrus",
"path": "walrus/lock.py",
"copies": "1",
"size": "4566",
"license": "mit",
"hash": 6251427804450158000,
"line_mean": 33.3308270677,
"line_max": 87,
"alpha_frac": 0.6009636443,
"autogenerated": false,
"ratio": 4.3156899810964084,
"config_test": false,
"has_no_... |
from functools import wraps
import os
def restoring_chdir(fn):
#XXX:dc: This would be better off in a neutral module
@wraps(fn)
def decorator(*args, **kw):
try:
path = os.getcwd()
return fn(*args, **kw)
finally:
os.chdir(path)
return decorator
clas... | {
"repo_name": "alex/readthedocs.org",
"path": "readthedocs/doc_builder/base.py",
"copies": "1",
"size": "2231",
"license": "mit",
"hash": -2747644196715697700,
"line_mean": 26.5432098765,
"line_max": 80,
"alpha_frac": 0.6069027342,
"autogenerated": false,
"ratio": 4.746808510638298,
"config_tes... |
from functools import wraps
import os, os.path
import shutil
import subprocess
import numpy
from scipy import special
import apogee.tools.read as apread
import apogee.tools.path as appath
from apogee.tools import toAspcapGrid,_aspcapPixelLimits
from apogee.spec.plot import apStarWavegrid
def specFitInput(func):
"""... | {
"repo_name": "jobovy/apogee",
"path": "apogee/modelspec/__init__.py",
"copies": "1",
"size": "6784",
"license": "bsd-3-clause",
"hash": -1198916432249181000,
"line_mean": 44.2266666667,
"line_max": 237,
"alpha_frac": 0.6133549528,
"autogenerated": false,
"ratio": 3.4279939363314806,
"config_te... |
from functools import wraps
import os.path
import theano
from theano import config
from theano import tensor as T
from theano.sandbox.cuda import GpuOp, as_cuda_ndarray_variable, device_properties
from theano.sandbox.cuda.basic_ops import (gpu_contiguous, GpuFromHost, HostFromGpu,
... | {
"repo_name": "stanfordnlp/spinn",
"path": "python/spinn/util/cuda.py",
"copies": "1",
"size": "50063",
"license": "mit",
"hash": -5141168164329313000,
"line_mean": 33.7901320361,
"line_max": 129,
"alpha_frac": 0.5163294249,
"autogenerated": false,
"ratio": 3.571591638724406,
"config_test": fal... |
from functools import wraps
import pandas as pd
from arctic.chunkstore.chunkstore import ChunkStore
import pytech.utils as utils
from pytech.mongo import ARCTIC_STORE, BarStore
from pytech.utils.exceptions import InvalidStoreError, PyInvestmentKeyError
from pandas.tseries.offsets import BDay
from pytech.data._holders... | {
"repo_name": "kprestel/PyInvestment",
"path": "pytech/decorators/decorators.py",
"copies": "2",
"size": "4087",
"license": "mit",
"hash": 7719846952224752000,
"line_mean": 31.1811023622,
"line_max": 78,
"alpha_frac": 0.576951309,
"autogenerated": false,
"ratio": 4.087,
"config_test": false,
... |
from functools import wraps
import pickle
from .backends import LocalBackend, MemcacheBackend
from .decorators import CachedFunctionDecorator, CachedListFunctionDecorator
from .utils import default_cache_key_func
from .batcher import Batcher
from .exceptions import InvalidHookEventException, OutOfBatcherContextRegistr... | {
"repo_name": "garindra/pycacher",
"path": "pycacher/cacher.py",
"copies": "1",
"size": "4282",
"license": "mit",
"hash": -5680126116662343000,
"line_mean": 29.5857142857,
"line_max": 91,
"alpha_frac": 0.5765997198,
"autogenerated": false,
"ratio": 4.391794871794872,
"config_test": false,
"ha... |
from functools import wraps
import pyavali
from .argumentpickers import create_argument_picker
class validate(object):
"""Validates a function argument by calling validator with the argument.
@validate(0, int)
def foo(param):
...
or
@validate("param", int, "must be int")
def foo(param)
...
ar... | {
"repo_name": "mlackman/pyavali",
"path": "pyavali/decorators.py",
"copies": "1",
"size": "2175",
"license": "apache-2.0",
"hash": -3368731539542886000,
"line_mean": 28.3918918919,
"line_max": 107,
"alpha_frac": 0.6937931034,
"autogenerated": false,
"ratio": 3.9617486338797816,
"config_test": f... |
from functools import wraps
import pytz
import heapq
from annoying.functions import get_object_or_None
from django.core.exceptions import PermissionDenied
from django.utils import timezone
from schedule.conf.settings import CHECK_EVENT_PERM_FUNC, CHECK_CALENDAR_PERM_FUNC
class EventListManager(object):
"""
Th... | {
"repo_name": "erezlife/django-scheduler",
"path": "schedule/utils.py",
"copies": "1",
"size": "4739",
"license": "bsd-3-clause",
"hash": -3897363481879476700,
"line_mean": 33.3405797101,
"line_max": 120,
"alpha_frac": 0.6254484068,
"autogenerated": false,
"ratio": 4.27321911632101,
"config_tes... |
from functools import wraps
import pytz
import heapq
from annoying.functions import get_object_or_None
from django.http import HttpResponseRedirect
from django.conf import settings
from django.utils import timezone
from schedule.conf.settings import CHECK_EVENT_PERM_FUNC, CHECK_CALENDAR_PERM_FUNC
class EventListManag... | {
"repo_name": "jrutila/django-schedule",
"path": "schedule/utils.py",
"copies": "2",
"size": "4815",
"license": "bsd-3-clause",
"hash": 2540940516127492000,
"line_mean": 33.6402877698,
"line_max": 120,
"alpha_frac": 0.6288681205,
"autogenerated": false,
"ratio": 4.2686170212765955,
"config_test... |
from functools import wraps
import pytz
import heapq
import datetime
from annoying.functions import get_object_or_None
from django.http import HttpResponseRedirect, HttpResponseNotFound
from django.conf import settings
from django.utils import timezone
from django.utils.module_loading import import_string
from schedule... | {
"repo_name": "nwaxiomatic/django-scheduler",
"path": "schedule/utils.py",
"copies": "1",
"size": "11438",
"license": "bsd-3-clause",
"hash": -6739619643359573000,
"line_mean": 35.9,
"line_max": 124,
"alpha_frac": 0.6129568106,
"autogenerated": false,
"ratio": 4.183613752743233,
"config_test": ... |
from functools import wraps
import random
import copy
from axelrod import Actions, flip_action
from .game import DefaultGame
C, D = Actions.C, Actions.D
# Strategy classifiers
def is_basic(s):
"""
Defines criteria for a strategy to be considered 'basic'
"""
stochastic = s.classifier['stochastic']
... | {
"repo_name": "ranjinidas/Axelrod",
"path": "axelrod/player.py",
"copies": "1",
"size": "4878",
"license": "mit",
"hash": 2827035234594652700,
"line_mean": 29.679245283,
"line_max": 132,
"alpha_frac": 0.6193111931,
"autogenerated": false,
"ratio": 4.130397967823878,
"config_test": false,
"has... |
from functools import wraps
import random
from django.test import TestCase
from tt_streams import factories as streams
from . import factories
from . import models
def with_stream_stories_and_videos(func):
@wraps(func)
def inner(self, *args, **kwargs):
stream = streams.StreamFactory.create()
... | {
"repo_name": "texastribune/tt_streams",
"path": "example/app/tests.py",
"copies": "1",
"size": "2735",
"license": "apache-2.0",
"hash": 428332087722356160,
"line_mean": 35.4666666667,
"line_max": 78,
"alpha_frac": 0.6702010969,
"autogenerated": false,
"ratio": 3.7363387978142075,
"config_test"... |
from functools import wraps
import random, string, json
from flask import Blueprint, request, redirect, Response, render_template, flash, url_for, current_app, session
from forms import AddForm, LoginForm
import database_helper
admin_page = Blueprint("admin", __name__)
# General helpers
def get_random_shortcode(... | {
"repo_name": "AndrewNeo/hybridius",
"path": "admin.py",
"copies": "1",
"size": "6102",
"license": "mit",
"hash": 1139945413780670000,
"line_mean": 29.8181818182,
"line_max": 156,
"alpha_frac": 0.6401179941,
"autogenerated": false,
"ratio": 3.700424499696786,
"config_test": false,
"has_no_key... |
from functools import wraps
import re
from typing import Optional, Callable, Union, Pattern, Any
from .threads import JobThread
# utility functions for doing dynamic replacements in matches
_replace_format = re.compile(r':(\w*):')
def _replace_match(self, match) -> str:
if match[1] in self.config['replace']:
... | {
"repo_name": "techborn/pIRC",
"path": "hooks.py",
"copies": "1",
"size": "13402",
"license": "mit",
"hash": 4390673162589603000,
"line_mean": 28.3260393873,
"line_max": 109,
"alpha_frac": 0.5766303537,
"autogenerated": false,
"ratio": 4.214465408805031,
"config_test": false,
"has_no_keywords... |
from functools import wraps
import re
import socket
import struct
import time
import gevent
import requests
def tz_hours():
delta = time.localtime().tm_hour - time.gmtime().tm_hour
sign = '-' if delta < 0 else ''
return "%s%02d.00" % (sign, abs(delta))
def is_dst():
return 1 if time.localtime().tm_... | {
"repo_name": "sstangle73/ouimeaux",
"path": "ouimeaux/utils.py",
"copies": "9",
"size": "2252",
"license": "bsd-3-clause",
"hash": -1481027924456971000,
"line_mean": 24.0222222222,
"line_max": 124,
"alpha_frac": 0.6221136767,
"autogenerated": false,
"ratio": 3.55205047318612,
"config_test": fa... |
from functools import wraps
import re
import sys
import django
from django.db.models import F, NOT_PROVIDED
from django.db.models.sql import aggregates as sqlaggregates
from django.db.models.sql.constants import MULTI
from django.db.models.sql.where import OR
from django.db.utils import DatabaseError, IntegrityError
f... | {
"repo_name": "cjaffar/jaffarchiosa",
"path": "jaffarchiosa/lib/python2.7/site-packages/django_mongodb_engine/compiler.py",
"copies": "1",
"size": "16906",
"license": "mit",
"hash": -5405475740151193000,
"line_mean": 36.9058295964,
"line_max": 81,
"alpha_frac": 0.5025434757,
"autogenerated": false,... |
from functools import wraps
import re
import traceback
from django.http import HttpResponseForbidden
from django.views.decorators.csrf import csrf_exempt
from watchman import settings
def check(func):
"""
Decorator which wraps checks and returns an error response on failure.
"""
def wrapped(*args, *... | {
"repo_name": "blag/django-watchman",
"path": "watchman/decorators.py",
"copies": "2",
"size": "3160",
"license": "bsd-3-clause",
"hash": 6452464763305423000,
"line_mean": 28.8113207547,
"line_max": 90,
"alpha_frac": 0.6170886076,
"autogenerated": false,
"ratio": 4.005069708491762,
"config_test... |
from functools import wraps
import re
from django.conf import settings
from django.contrib.auth import REDIRECT_FIELD_NAME
from django.contrib.auth.decorators import user_passes_test
from django.core.exceptions import PermissionDenied
from django.http import HttpResponseForbidden, HttpResponseRedirect
from django.util... | {
"repo_name": "yfdyh000/kuma",
"path": "kuma/core/decorators.py",
"copies": "1",
"size": "5280",
"license": "mpl-2.0",
"hash": 3233299262566167000,
"line_mean": 37.2608695652,
"line_max": 79,
"alpha_frac": 0.6392045455,
"autogenerated": false,
"ratio": 4.0121580547112465,
"config_test": false,
... |
from functools import wraps
import re
from flask import Blueprint, g, make_response
from mcavatar import app
from mcavatar.avatar import Avatar
img = Blueprint('img', __name__)
username_re = re.compile('([A-Z_0-9]){2,16}', re.I)
d_size = app.config.get('DEFAULT_IMG_SIZE', 48)
max_size = app.config.get('MAX_IMG_SIZ... | {
"repo_name": "joealcorn/MCAvatar",
"path": "mcavatar/views/img/__init__.py",
"copies": "1",
"size": "1841",
"license": "mit",
"hash": 1117927935651683500,
"line_mean": 22.6025641026,
"line_max": 54,
"alpha_frac": 0.5812058664,
"autogenerated": false,
"ratio": 3.130952380952381,
"config_test": ... |
from functools import wraps
import requests
from dbt.exceptions import RegistryException
from dbt.utils import memoized
from dbt.logger import GLOBAL_LOGGER as logger
import os
import time
if os.getenv('DBT_PACKAGE_HUB_URL'):
DEFAULT_REGISTRY_BASE_URL = os.getenv('DBT_PACKAGE_HUB_URL')
else:
DEFAULT_REGISTRY_B... | {
"repo_name": "analyst-collective/dbt",
"path": "core/dbt/clients/registry.py",
"copies": "2",
"size": "2058",
"license": "apache-2.0",
"hash": 3729777574725439500,
"line_mean": 26.8108108108,
"line_max": 78,
"alpha_frac": 0.6253644315,
"autogenerated": false,
"ratio": 3.6947935368043088,
"conf... |
from functools import wraps
import secrets
from django.core.signing import TimestampSigner, SignatureExpired
from django.shortcuts import redirect, render
from hc.api.models import TokenBucket
from hc.lib import emails
def _session_unsign(request, key, max_age):
if key not in request.session:
return None... | {
"repo_name": "healthchecks/healthchecks",
"path": "hc/accounts/decorators.py",
"copies": "2",
"size": "1683",
"license": "bsd-3-clause",
"hash": -6255282899579065000,
"line_mean": 32,
"line_max": 78,
"alpha_frac": 0.6274509804,
"autogenerated": false,
"ratio": 3.886836027713626,
"config_test":... |
from functools import wraps
import shutil
import tempfile
import os
import pytest
def pytest_addoption(parser):
group = parser.getgroup('fits', 'Fits comparison')
group.addoption('--runtest', action='store_true',
help="Enable comparison of fits images")
group.addoption('--generate-ima... | {
"repo_name": "guaix-ucm/pytest-fits",
"path": "tests/conftest.py",
"copies": "2",
"size": "5322",
"license": "bsd-3-clause",
"hash": 2789905307434596400,
"line_mean": 37.2877697842,
"line_max": 112,
"alpha_frac": 0.5612551672,
"autogenerated": false,
"ratio": 4.564322469982847,
"config_test": ... |
from functools import wraps
import six
import requests
from dbt.exceptions import RegistryException
from dbt.utils import memoized
import os
if os.getenv('DBT_PACKAGE_HUB_URL'):
DEFAULT_REGISTRY_BASE_URL = os.getenv('DBT_PACKAGE_HUB_URL')
else:
DEFAULT_REGISTRY_BASE_URL = 'https://hub.getdbt.com/'
def _get_u... | {
"repo_name": "nave91/dbt",
"path": "dbt/clients/registry.py",
"copies": "1",
"size": "1562",
"license": "apache-2.0",
"hash": 4843871729963999000,
"line_mean": 24.606557377,
"line_max": 77,
"alpha_frac": 0.6805377721,
"autogenerated": false,
"ratio": 3.316348195329087,
"config_test": false,
... |
from functools import wraps
import sys
from asyncio import Queue, coroutine, iscoroutine, async, Future, gather
import logging
import inspect
logger = logging.getLogger('octobot:EventManager')
class RegistrationException: pass
class _EventManager(object):
def __init__(self):
providers = {}
self.... | {
"repo_name": "Thezomg/OctoBot",
"path": "octobot/events.py",
"copies": "1",
"size": "4667",
"license": "mit",
"hash": -8123870506636604000,
"line_mean": 31.1862068966,
"line_max": 118,
"alpha_frac": 0.5069637883,
"autogenerated": false,
"ratio": 4.504826254826255,
"config_test": false,
"has_... |
from functools import wraps
import sys
from collections import OrderedDict
from . import ui, decorators
# TODO - Add doc strings
# TODO - Add better comments
#-----------------------------------------------------------------------------#
# Helper Functions
#----------------------------------------------------------... | {
"repo_name": "andytom/navigator",
"path": "navigator/navigator.py",
"copies": "1",
"size": "3279",
"license": "bsd-3-clause",
"hash": -7279851727161895000,
"line_mean": 29.3611111111,
"line_max": 110,
"alpha_frac": 0.5215004575,
"autogenerated": false,
"ratio": 4.19309462915601,
"config_test":... |
from functools import wraps
import sys
from etcd import client
from conf.appconfig import HEALTH_OK, HEALTH_FAILED, TOTEM_ETCD_SETTINGS
from orchestrator.services.storage.factory import get_store
from orchestrator.tasks.common import ping
from orchestrator.util import timeout
HEALTH_TIMEOUT_SECONDS = 10
def _check(f... | {
"repo_name": "totem/cluster-orchestrator",
"path": "orchestrator/services/health.py",
"copies": "1",
"size": "2266",
"license": "mit",
"hash": 2282720362820664300,
"line_mean": 24.4606741573,
"line_max": 74,
"alpha_frac": 0.6306266549,
"autogenerated": false,
"ratio": 3.9615384615384617,
"conf... |
from functools import wraps
import sys
from flask import Flask, request, abort, g, jsonify, render_template
from src.db.models import Group, User, email_is_valid, Invite
from src.db.database import Database
from flask.ext.cors import CORS, cross_origin
import datetime
import jinja2
import os
import logging
# Defaults ... | {
"repo_name": "jslvtr/FriendFinderBackend",
"path": "src/app/FriendFinderBackend.py",
"copies": "1",
"size": "11417",
"license": "mit",
"hash": -8175559130737210000,
"line_mean": 27.1231527094,
"line_max": 97,
"alpha_frac": 0.6031356749,
"autogenerated": false,
"ratio": 3.801864801864802,
"conf... |
from functools import wraps
import sys
import datetime
import re
import sys
import os
import time
import traceback
import cgitb
import cgi
from ast import literal_eval as eval
from collections import OrderedDict as odict
from operator import eq, gt, lt, contains
from shot.exc import ShotException, RouteNotFoundError, ... | {
"repo_name": "2peppers/shot",
"path": "build/lib/shot/__init__.py",
"copies": "1",
"size": "4642",
"license": "mit",
"hash": 8182177842844190000,
"line_mean": 36.136,
"line_max": 116,
"alpha_frac": 0.5327445067,
"autogenerated": false,
"ratio": 4.2276867030965395,
"config_test": false,
"has_... |
from functools import wraps
import sys
import datetime
import re
import sys
import os
import time
import traceback
import cgitb
import cgi
from wsgiref.simple_server import make_server
from collections import OrderedDict as odict
from operator import eq, gt, lt, contains
from shot.exc import RouteFormatError, RouteNot... | {
"repo_name": "2peppers/shot",
"path": "shot/__init__.py",
"copies": "1",
"size": "6870",
"license": "mit",
"hash": 8146471874253181000,
"line_mean": 35.7379679144,
"line_max": 115,
"alpha_frac": 0.534643377,
"autogenerated": false,
"ratio": 4.0917212626563435,
"config_test": false,
"has_no_k... |
from functools import wraps
import sys
import logging
from django.db.models.fields import AutoField
from django.db.models.sql import aggregates as sqlaggregates
from django.db.models.sql.constants import LOOKUP_SEP, MULTI, SINGLE
from django.db.models.sql.where import AND, OR
from django.db.utils import DatabaseError,... | {
"repo_name": "potatolondon/djangoappengine-1-4",
"path": "db/compiler.py",
"copies": "1",
"size": "22103",
"license": "bsd-3-clause",
"hash": 6222663851229825000,
"line_mean": 35.3536184211,
"line_max": 133,
"alpha_frac": 0.529611365,
"autogenerated": false,
"ratio": 4.351840913565662,
"config... |
from functools import wraps
import sys
import os
from datetime import datetime
import logging
import requests
class TinyETL:
"""Manages facts about an ETL Process.
Provides a consistent interface for storing log location,
temporary data locations, and a way to facilitate dry-run
and logging on Fabric-... | {
"repo_name": "joedougherty/tinyetl",
"path": "tinyetl/__init__.py",
"copies": "1",
"size": "5343",
"license": "mit",
"hash": -6326519522383648000,
"line_mean": 32.6037735849,
"line_max": 116,
"alpha_frac": 0.5730862811,
"autogenerated": false,
"ratio": 3.8801742919389977,
"config_test": false,... |
from functools import wraps
import sys
from django.db.models.fields import AutoField
from django.db.models.sql import aggregates as sqlaggregates
from django.db.models.sql.constants import LOOKUP_SEP, MULTI, SINGLE
from django.db.models.sql.where import AND, OR
from django.db.utils import DatabaseError, IntegrityError... | {
"repo_name": "adamjmcgrath/glancydesign",
"path": "src/djangoappengine/djangoappengine/db/compiler.py",
"copies": "17",
"size": "15681",
"license": "bsd-3-clause",
"hash": -3842851499709031400,
"line_mean": 34.9655963303,
"line_max": 133,
"alpha_frac": 0.5428862955,
"autogenerated": false,
"rati... |
from functools import wraps
import sys
import capybara
from capybara import DSL_METHODS as PACKAGE_METHODS
from capybara.session import DSL_METHODS as SESSION_METHODS, Session
__all__ = ["page"] + SESSION_METHODS + PACKAGE_METHODS
class Page(object):
""" A proxy for the current session. """
def __getattr__... | {
"repo_name": "elliterate/capybara.py",
"path": "capybara/dsl.py",
"copies": "1",
"size": "1126",
"license": "mit",
"hash": 6873009616045145000,
"line_mean": 20.6538461538,
"line_max": 68,
"alpha_frac": 0.6811722913,
"autogenerated": false,
"ratio": 3.4224924012158056,
"config_test": false,
"... |
from functools import wraps
import sys
def memo(func):
cache = {}
@wraps(func)
def wrap(*arg):
if arg not in cache:
cache[arg] = func(*arg)
print cache
return wrap
class TailRecurseException:
def __init__(self, args, kwargs):
self.args = args
self.kwa... | {
"repo_name": "liuyang1/euler",
"path": "014_1.py",
"copies": "1",
"size": "1185",
"license": "mit",
"hash": 2508842122174131700,
"line_mean": 20.1607142857,
"line_max": 52,
"alpha_frac": 0.4978902954,
"autogenerated": false,
"ratio": 3.2465753424657535,
"config_test": false,
"has_no_keywords... |
from functools import wraps
import sys
# sys.path.append('../')
from util.util import print_trace_exception
class ServiceException(Exception):
pass
class ServiceHandlerMissingException(ServiceException):
pass
def register(_self):
def outer_wrapper(func):
_self.add_handler(func)
@wraps... | {
"repo_name": "dyf102/Gomoku-online",
"path": "server/service/baseservice.py",
"copies": "1",
"size": "1839",
"license": "apache-2.0",
"hash": 153375165129741000,
"line_mean": 21.9875,
"line_max": 55,
"alpha_frac": 0.5927134312,
"autogenerated": false,
"ratio": 3.9463519313304722,
"config_test"... |
from functools import wraps
import time
from flask import Flask, abort, request, render_template
import backend.utils as utils
from backend.grid_manager import GridManager
app = Flask(__name__)
TOKEN = "abc"
GMS = dict(mgm=None, hgm=None)
BOXES = []
@app.after_request
def add_cors(resp):
""" Ensure all responses... | {
"repo_name": "mgpjohny/grid-pair-management",
"path": "main.py",
"copies": "1",
"size": "2366",
"license": "mit",
"hash": 8959414316161748000,
"line_mean": 29.3333333333,
"line_max": 104,
"alpha_frac": 0.6213017751,
"autogenerated": false,
"ratio": 3.34180790960452,
"config_test": false,
"ha... |
from functools import wraps
import time
from hashlib import md5
import threading
class memoize(object):
""" Memoize the results of a function. Supports an optional timeout
for automatic cache expiration.
If the optional manual_flush argument is True, a function called
"flush_cache" will b... | {
"repo_name": "carlsverre/wraptor",
"path": "wraptor/decorators/memoize.py",
"copies": "3",
"size": "2632",
"license": "mit",
"hash": -5729054447542369000,
"line_mean": 36.6,
"line_max": 94,
"alpha_frac": 0.5623100304,
"autogenerated": false,
"ratio": 4.545768566493955,
"config_test": false,
... |
from functools import wraps
import time
import inspect
from . import helpers
def memoize(ttl_spec, whitelist=None, blacklist=None,
key_fn=helpers._json_keyify, backend=lambda fn: dict(),
get_now=time.time):
""" memoize/cache the decorated function for ttl amount of time """
ttl = helpers._ti... | {
"repo_name": "tuborgclassic/carlsberg",
"path": "memoize/decorator.py",
"copies": "1",
"size": "1369",
"license": "mit",
"hash": 4896249363222992000,
"line_mean": 28.7608695652,
"line_max": 80,
"alpha_frac": 0.565376187,
"autogenerated": false,
"ratio": 4.264797507788162,
"config_test": false,... |
from functools import wraps
import time
import logging
from peewee import Model
import peewee
from playhouse.postgres_ext import PostgresqlExtDatabase
from redash import statsd_client
metrics_logger = logging.getLogger("metrics")
class MeteredPostgresqlExtDatabase(PostgresqlExtDatabase):
def __init__(self, *args... | {
"repo_name": "olivetree123/redash-x",
"path": "redash/metrics/database.py",
"copies": "1",
"size": "3358",
"license": "bsd-2-clause",
"hash": -7198786763810441000,
"line_mean": 31.9215686275,
"line_max": 118,
"alpha_frac": 0.6381774866,
"autogenerated": false,
"ratio": 3.8955916473317864,
"con... |
from functools import wraps
import time
import logging
from playhouse.gfk import Model
import peewee
from playhouse.postgres_ext import PostgresqlExtDatabase
from redash import statsd_client
metrics_logger = logging.getLogger("metrics")
class MeteredPostgresqlExtDatabase(PostgresqlExtDatabase):
def __init__(self... | {
"repo_name": "jmvasquez/redashtest",
"path": "redash/metrics/database.py",
"copies": "6",
"size": "3365",
"license": "bsd-2-clause",
"hash": -2488997687631142400,
"line_mean": 31.9901960784,
"line_max": 118,
"alpha_frac": 0.6386329866,
"autogenerated": false,
"ratio": 3.894675925925926,
"confi... |
from functools import wraps
import time
import traceback
import inspect
import threading
import types
class LoggerException(Exception):
pass
class ReturnTypeMismatchError(Exception):
pass
def _raiseReturnTypeMismatchError(expctedType, actualType):
raise ReturnTypeMismatchError(
"Type mismatch:... | {
"repo_name": "lbusoni/pi_gcs",
"path": "pi_gcs/decorator.py",
"copies": "1",
"size": "4972",
"license": "mit",
"hash": -424292062654775400,
"line_mean": 23.1359223301,
"line_max": 70,
"alpha_frac": 0.5663716814,
"autogenerated": false,
"ratio": 4.2459436379163105,
"config_test": false,
"has_... |
from functools import wraps
import time
from app.util import log
from app.util.exceptions import AuthenticationError
from app.util.secret import Secret
def retry_on_exception_exponential_backoff(exceptions, initial_delay=0.1, total_delay=15, exponential_factor=2):
"""
Retries with exponential backoff.
:... | {
"repo_name": "josephharrington/ClusterRunner",
"path": "app/util/decorators.py",
"copies": "4",
"size": "2676",
"license": "apache-2.0",
"hash": 8203389082012148000,
"line_mean": 40.1692307692,
"line_max": 116,
"alpha_frac": 0.6255605381,
"autogenerated": false,
"ratio": 4.597938144329897,
"co... |
from functools import wraps
import time
from .static import static
def once_every(n):
""" run the wrapped function only every nth call after the first call """
def outer(func):
@wraps(func)
@static(ncalls=0, ncalls_actual=0, ncalls_filtered=0)
def inner(*args, **kwargs):
i... | {
"repo_name": "bigblindbais/pytk",
"path": "src/pytk/decorators/once_every.py",
"copies": "1",
"size": "1148",
"license": "mit",
"hash": -5455107862702851000,
"line_mean": 29.2105263158,
"line_max": 77,
"alpha_frac": 0.5400696864,
"autogenerated": false,
"ratio": 4.056537102473499,
"config_test... |
from functools import wraps
import time
from ._util import maybe_labels
class Timer:
"""A Timer instance for instrumenting function runs,
or arbitrary pieces of code.
Usage:
stats = Stats('greasyspoon')
with stats.timed(
'eggs',
tags=['spam:ham'],
... | {
"repo_name": "Intel471/prom-stats",
"path": "promstats/_timer.py",
"copies": "1",
"size": "1601",
"license": "mit",
"hash": -3822540687229413000,
"line_mean": 25.6833333333,
"line_max": 70,
"alpha_frac": 0.5315427858,
"autogenerated": false,
"ratio": 4.0327455919395465,
"config_test": false,
... |
from functools import wraps
import time
from vomitter import LOGGER as L
from .response import json_error
def validate_form_data(FORM_Class):
"""
Validates the passed form/json data to a request and passes the
form to the called function.
If form data is not valid, return a 406 response.
"""
... | {
"repo_name": "brijeshb42/yapper",
"path": "yapper/lib/decorators.py",
"copies": "1",
"size": "1144",
"license": "mit",
"hash": 131100134475295250,
"line_mean": 26.2380952381,
"line_max": 67,
"alpha_frac": 0.590034965,
"autogenerated": false,
"ratio": 3.763157894736842,
"config_test": false,
... |
from functools import wraps
import time
__author__ = "Aaron Koeppel"
__version__ = 1.0
def retry(ExceptionToCheck, logger, tries=4, delay=3, backoff=2):
"""Retry calling the decorated function using an exponential backoff.
http://www.saltycrane.com/blog/2009/11/trying-out-retry-decorator-python/
origina... | {
"repo_name": "ak212/python-basketball-rss",
"path": "retry_decorator.py",
"copies": "1",
"size": "1533",
"license": "mit",
"hash": 5367840583812542000,
"line_mean": 30.9375,
"line_max": 76,
"alpha_frac": 0.6073059361,
"autogenerated": false,
"ratio": 3.9921875,
"config_test": false,
"has_no_... |
from functools import wraps
import time
class limit(object):
class Exception(BaseException):
pass
def __init__(self, per_second=None, per_minute=None):
self.period = 0.0
self.max_calls = 0
if per_second:
self.period = 1.0
self.max_calls = per_second
... | {
"repo_name": "vladignatyev/limiter",
"path": "limiter/limiter/__init__.py",
"copies": "1",
"size": "1216",
"license": "mit",
"hash": 592909721133228400,
"line_mean": 30.1794871795,
"line_max": 71,
"alpha_frac": 0.515625,
"autogenerated": false,
"ratio": 4.2369337979094075,
"config_test": false... |
from functools import wraps
import traceback
import sys
from flask import Flask, request, jsonify, current_app
from yaqluator import yaqluator
from utils import files
# init the Flask app
app = Flask(__name__)
def jsonp(func):
"""Wraps JSONified output for JSONP requests."""
@wraps(func)
def decorated... | {
"repo_name": "ALU-CloudBand/yaqluator",
"path": "python/api.py",
"copies": "1",
"size": "3371",
"license": "mit",
"hash": 3054387869228121000,
"line_mean": 31.7281553398,
"line_max": 134,
"alpha_frac": 0.6588549392,
"autogenerated": false,
"ratio": 3.7084708470847083,
"config_test": false,
"... |
from functools import wraps
import traceback
from .data_collection import DataCollection
from .data_factories import load_data
from . import command
from . import Data, Subset
from .hub import HubListener
from .util import PropertySetMixin
from .edit_subset_mode import EditSubsetMode
from .session import Session
from ... | {
"repo_name": "bsipocz/glue",
"path": "glue/core/application_base.py",
"copies": "1",
"size": "10124",
"license": "bsd-3-clause",
"hash": -5930902332769742000,
"line_mean": 27.5988700565,
"line_max": 75,
"alpha_frac": 0.580501778,
"autogenerated": false,
"ratio": 4.337617823479006,
"config_test... |
from functools import wraps
import traceback
from reportmail.reporter import Reporter
def apply_reporter(subject, template='reportmail/command_report.txt', committer=None,
reporter_cls=Reporter, additional_context=None):
""" Adding a reporting feature for django command
You can use this a... | {
"repo_name": "hirokiky/django-reportmail",
"path": "reportmail/command.py",
"copies": "1",
"size": "2136",
"license": "mit",
"hash": -2368367674827926500,
"line_mean": 35.2033898305,
"line_max": 87,
"alpha_frac": 0.6189138577,
"autogenerated": false,
"ratio": 4.736141906873614,
"config_test": ... |
from functools import wraps
import traceback
from smoothie.exc import CallableCallbackException
class Dispenser(object):
def __init__(self):
self.map = {}
def attach(self, exception=Exception, callback=None):
'''
decorator needed to be attached to functions or
class function... | {
"repo_name": "TheSriram/smoothie",
"path": "smoothie/king.py",
"copies": "1",
"size": "1265",
"license": "apache-2.0",
"hash": -6122995495654560000,
"line_mean": 27.1111111111,
"line_max": 67,
"alpha_frac": 0.5351778656,
"autogenerated": false,
"ratio": 5.205761316872428,
"config_test": false,... |
from functools import wraps
import urlparse
from django.contrib.auth import REDIRECT_FIELD_NAME
from django.utils.decorators import available_attrs
from django.conf import settings
from django.http import HttpResponseRedirect
from pymongo.cursor import Cursor
from onadata.apps.logger.models import XForm
def check_o... | {
"repo_name": "awemulya/fieldsight-kobocat",
"path": "onadata/libs/utils/decorators.py",
"copies": "11",
"size": "3041",
"license": "bsd-2-clause",
"hash": 216284171471084500,
"line_mean": 39.0131578947,
"line_max": 75,
"alpha_frac": 0.5810588622,
"autogenerated": false,
"ratio": 4.33190883190883... |
from functools import wraps
import weakref
from asyncio import coroutine, gather
class Named:
def __init__(self, *args, name, **kws):
super().__init__(*args, **kws)
self.name = name
class Annotate(Named):
""" annotation that is transformed to a class """
def __new__(cls, definition):
... | {
"repo_name": "wabu/pyadds",
"path": "pyadds/annotate.py",
"copies": "1",
"size": "5010",
"license": "mit",
"hash": -2858577644568930000,
"line_mean": 24.9585492228,
"line_max": 88,
"alpha_frac": 0.5610778443,
"autogenerated": false,
"ratio": 4.296740994854202,
"config_test": false,
"has_no_k... |
from functools import wraps
import weakref
from asyncio import coroutine
from supplies.coop import Named
__author__ = 'dwae'
__all__ = ['delay', 'refer', 'update', 'attr']
class Annotate(Named):
"""
The Annotate class wraps an annotated definition into an object
"""
def __new__(cls, *args, **kws):... | {
"repo_name": "gameduell/pysupplies",
"path": "supplies/annotate.py",
"copies": "1",
"size": "4575",
"license": "mit",
"hash": 5911677979912173000,
"line_mean": 22.2233502538,
"line_max": 79,
"alpha_frac": 0.5916939891,
"autogenerated": false,
"ratio": 4.166666666666667,
"config_test": false,
... |
from functools import wraps
import weakref
class WeakableDict(dict):
"dict subclass that can accept weakrefs."
__slots__ = ('__weakref__')
class WeakKeyNonHashingDict:
"""
A mapping that uses object IDs instead of hashes to store values.
Similar to `weakref.WeakKeyDictionary`, this mapping doe... | {
"repo_name": "felipeochoa/fforms",
"path": "fforms/cache.py",
"copies": "1",
"size": "1553",
"license": "mit",
"hash": -4638858030060469000,
"line_mean": 24.4590163934,
"line_max": 77,
"alpha_frac": 0.603348358,
"autogenerated": false,
"ratio": 4.141333333333334,
"config_test": false,
"has_n... |
from functools import wraps
__all__ = ('filter_powered',)
def filter_powered(filterform_cls, queryset_name='object_list', pass_params=False,
add_count=False, aggregate_args={}, values_spec=None, deferred=None):
def decorator(view):
@wraps(view)
def filter_powered_view(request, *args, **... | {
"repo_name": "freevoid/django-datafilters",
"path": "datafilters/decorators.py",
"copies": "2",
"size": "1948",
"license": "mit",
"hash": -6595863497984341000,
"line_mean": 34.4181818182,
"line_max": 82,
"alpha_frac": 0.5590349076,
"autogenerated": false,
"ratio": 4.994871794871795,
"config_te... |
from functools import wraps
__all__ = ['memoize', 'singleton', 'memoize_attr_check']
def _make_key(args, kwargs):
return args, frozenset(kwargs.items())
def memoize(func):
"""Save results of function calls to avoid repeated calculation"""
memo = {}
@wraps(func)
def wrapper(*args, **kwargs):
... | {
"repo_name": "glue-viz/glue-qt",
"path": "glue/core/decorators.py",
"copies": "2",
"size": "1549",
"license": "bsd-3-clause",
"hash": -1513483216212461000,
"line_mean": 23.5873015873,
"line_max": 76,
"alpha_frac": 0.5978050355,
"autogenerated": false,
"ratio": 4.2554945054945055,
"config_test"... |
from functools import wraps
__all__ = [
'singleton',
'memoize',
'cached_property',
]
def singleton(func):
"""
Decorator that creates a singleton instance.
If the method is called later a cached instance of the method is returned.
"""
cache = {}
@wraps(func)
def getinstance(*a... | {
"repo_name": "joeljames/py-shared-utils",
"path": "pysharedutils/decorators.py",
"copies": "1",
"size": "1378",
"license": "mit",
"hash": 4409329922655300600,
"line_mean": 23.6071428571,
"line_max": 78,
"alpha_frac": 0.5957910015,
"autogenerated": false,
"ratio": 4.089020771513353,
"config_tes... |
from functools import wraps
class ActFormatter():
@classmethod
def default_format(cls, dict_input):
return dict_input
_formatter = default_format
@classmethod
def decorate (cls, formatter_func, **kwargs):
@wraps(formatter_func)
def wprapper_func():
return ActFormatter._formatter(formatte... | {
"repo_name": "Actifio/actifio-python-package",
"path": "Actifio/formatting.py",
"copies": "1",
"size": "1606",
"license": "mit",
"hash": 6354897483139592000,
"line_mean": 26.6896551724,
"line_max": 86,
"alpha_frac": 0.5666251557,
"autogenerated": false,
"ratio": 3.4837310195227764,
"config_tes... |
from functools import wraps
class DebugWrapper():
"""
wraps nose. I want to make it so it can distribute out unittesting
to multiple cores.
"""
def listen(_self,func):
"""
Makes it so you can listen in on the contents of the function
call
"""
@wraps(func)
... | {
"repo_name": "uhjish/link",
"path": "link/debuglink.py",
"copies": "2",
"size": "1165",
"license": "apache-2.0",
"hash": 5113924740833815000,
"line_mean": 22.7755102041,
"line_max": 71,
"alpha_frac": 0.5167381974,
"autogenerated": false,
"ratio": 4.604743083003952,
"config_test": false,
"has... |
from functools import wraps
class exception_guard(object):
"""Guard against the given exception and raise a different exception."""
def __init__(self, catchable, throwable=RuntimeError):
if is_exception_class(catchable):
self._catchable = catchable
else:
raise TypeError... | {
"repo_name": "ActiveState/code",
"path": "recipes/Python/580808_Guard_against_exceptiwrong/recipe-580808.py",
"copies": "1",
"size": "3490",
"license": "mit",
"hash": -7291792093708387000,
"line_mean": 31.0183486239,
"line_max": 76,
"alpha_frac": 0.5865329513,
"autogenerated": false,
"ratio": 4.... |
from functools import wraps
def authorized_method(o):
o.authentication_required = o.slug
o.authorization_required = o.slug
return o
def authenticated_method(o):
o.authentication_required = o.slug
return o
def anonymous_method(o):
o.authentication_required = False
o.authorization_require... | {
"repo_name": "JeffHeard/sondra",
"path": "sondra/auth/decorators.py",
"copies": "1",
"size": "2213",
"license": "apache-2.0",
"hash": 8579606281507432000,
"line_mean": 34.126984127,
"line_max": 120,
"alpha_frac": 0.6836873023,
"autogenerated": false,
"ratio": 4.79004329004329,
"config_test": f... |
from functools import wraps
def countup(function):
@wraps(function)
def wrapper(*args, **kwargs):
result = function(*args, **kwargs)
return result + 1
return wrapper
def countdown(function):
@wraps(function)
def wrapper(*args, **kwargs):
result = function(*args, **kwargs)
... | {
"repo_name": "thinkAmi-sandbox/python_mock-sample",
"path": "e.g._mocking_decorator/deco/my_decorator.py",
"copies": "1",
"size": "1831",
"license": "unlicense",
"hash": -1749343161272080400,
"line_mean": 25.8333333333,
"line_max": 53,
"alpha_frac": 0.5997239476,
"autogenerated": false,
"ratio":... |
from functools import wraps
def decorate_with(*decorators):
"""decorate_with is a decorator that takes other decorators as input,
including their arguments (if any), and applies the them to the function
being decorated"""
def wrapper(func):
@wraps(func)
def func_wrapper(*args, **k... | {
"repo_name": "fredgj/mom",
"path": "mom/meta.py",
"copies": "1",
"size": "1171",
"license": "mit",
"hash": 7714672378214631000,
"line_mean": 39.3793103448,
"line_max": 79,
"alpha_frac": 0.4918872758,
"autogenerated": false,
"ratio": 5.34703196347032,
"config_test": false,
"has_no_keywords": ... |
from functools import wraps
def ensure_self(func):
"""
Decorator that can be used to ensure 'self' is the first argument on a task method.
This only needs to be used with task methods that are used as a callback to
a chord or in link_error and is really just a hack to get around https://github.com/cel... | {
"repo_name": "alexhayes/django-toolkit",
"path": "django_toolkit/celery/decorators.py",
"copies": "1",
"size": "1500",
"license": "mit",
"hash": -2459174211351932400,
"line_mean": 27.3018867925,
"line_max": 113,
"alpha_frac": 0.5673333333,
"autogenerated": false,
"ratio": 4.2979942693409745,
"... |
from functools import wraps
def InstanceDecorator(outerFunction):
'''
The decorated class method itself becomes a decorator
that is aware of the class instance's methods and attributes.
The second parameter after self must be the function you are
ultimately decorating.
Usage:
@InstanceDec... | {
"repo_name": "christopher-henderson/Experiments",
"path": "misc/instanceDecorator.py",
"copies": "1",
"size": "2085",
"license": "mit",
"hash": 8887916795642899000,
"line_mean": 42.4583333333,
"line_max": 88,
"alpha_frac": 0.5697841727,
"autogenerated": false,
"ratio": 5.238693467336684,
"conf... |
from functools import wraps
def iterit(*args, **kwargs):
"""
This takes some input (int, string, list, iterable, whatever) and
makes sure it is an iterable, making it a single item list if not.
Importantly, it does rational things with strings.
You can pass it more than one item. Cast is optional.... | {
"repo_name": "PaulMcMillan/eagleeye",
"path": "eagleeye/utils.py",
"copies": "2",
"size": "1051",
"license": "bsd-2-clause",
"hash": -6204193804945946000,
"line_mean": 23.4418604651,
"line_max": 72,
"alpha_frac": 0.5547098002,
"autogenerated": false,
"ratio": 3.5268456375838926,
"config_test":... |
from functools import wraps
def keymemo(key):
"""memoize decorator that applies the function key to the arguments
in order to retrieve the key to use in the cache dictionary"""
def memo(fn):
"""the memoize decorator itself"""
cache = {}
@wraps(fn)
def _fn(*args, **kwar... | {
"repo_name": "enricobacis/pg-distopt",
"path": "distopt/memo.py",
"copies": "1",
"size": "1687",
"license": "mit",
"hash": 5107233561582119000,
"line_mean": 28.5964912281,
"line_max": 78,
"alpha_frac": 0.5696502667,
"autogenerated": false,
"ratio": 4.134803921568627,
"config_test": false,
"h... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.