text
stringlengths
0
1.05M
meta
dict
from functools import wraps from os.path import join as path_join from urllib.parse import urljoin, urlparse, urlunparse from flask import current_app, request def jsonp(func): """Wraps JSONified output for JSONP requests.""" @wraps(func) def decorated(*args, **kwargs): callback = request.args.ge...
{ "repo_name": "guardian/alerta", "path": "alerta/utils/response.py", "copies": "1", "size": "1196", "license": "apache-2.0", "hash": -1715189264333980700, "line_mean": 37.5806451613, "line_max": 106, "alpha_frac": 0.6237458194, "autogenerated": false, "ratio": 4.081911262798635, "config_test": ...
from functools import wraps from os.path import join import docker from requests.exceptions import ReadTimeout from flask import current_app, request, Response, Blueprint from werkzeug import secure_filename from .exceptions import BuildException from .utils import docker_build, check_auth, check_image, mktmpdir c ...
{ "repo_name": "Mattias-/mym", "path": "mym/build.py", "copies": "1", "size": "2389", "license": "mit", "hash": -2094096206689067300, "line_mean": 34.1323529412, "line_max": 74, "alpha_frac": 0.6358308916, "autogenerated": false, "ratio": 4.205985915492958, "config_test": false, "has_no_keywor...
from functools import wraps from pastry.models import User from flask import request, abort, jsonify def parse_api_key(): key = None if request.args.get('api_key'): key = request.args.get('api_key') elif request.form.get('api_key'): key = request.form.get('api_key') return key def lo...
{ "repo_name": "cloughrm/Flask-Angular-Template", "path": "backend/pastry/resources/auth.py", "copies": "1", "size": "1383", "license": "mit", "hash": 2225794611409529900, "line_mean": 29.0652173913, "line_max": 53, "alpha_frac": 0.4873463485, "autogenerated": false, "ratio": 4.625418060200669, ...
from functools import wraps from path import path as ppath import flask from flaskext.openid import OpenID, COMMON_PROVIDERS from sqlitedict import SqliteDict oid = OpenID() auth = flask.Blueprint('auth', __name__) def _get_users_db(): return flask.current_app.extensions['auth-users']['usersdb'] def lookup_cu...
{ "repo_name": "eaudeweb/natura2000db", "path": "auth.py", "copies": "1", "size": "2004", "license": "bsd-3-clause", "hash": -5015305180744380000, "line_mean": 24.3670886076, "line_max": 73, "alpha_frac": 0.6412175649, "autogenerated": false, "ratio": 3.2115384615384617, "config_test": false, ...
from functools import wraps from plumeria import config from plumeria.config import set_of from plumeria.command import AuthorizationError, CommandError owner_ids = config.create("perms", "admin_users", set_of(str), fallback="") config.add(owner_ids) def has_role_in(user, roles): for role in user.roles: ...
{ "repo_name": "sk89q/Plumeria", "path": "plumeria/perms.py", "copies": "1", "size": "2874", "license": "mit", "hash": -5195527384829551000, "line_mean": 26.9029126214, "line_max": 120, "alpha_frac": 0.6113430759, "autogenerated": false, "ratio": 4.201754385964913, "config_test": false, "has_n...
from functools import wraps from pprint import pprint import json try: from urllib.parse import quote as url_quote except: from urllib import quote as url_quote from flask import Blueprint, g, session, render_template, url_for, request, jsonify from controllers.helpers import (lti, get_assignments_from_reques...
{ "repo_name": "RealTimeWeb/Blockpy-Server", "path": "controllers/assignments.py", "copies": "1", "size": "11052", "license": "mit", "hash": -8451600509893115000, "line_mean": 46.4377682403, "line_max": 245, "alpha_frac": 0.6445892146, "autogenerated": false, "ratio": 3.9741100323624594, "config...
from functools import wraps # from pprint import pprint from tornado.web import HTTPError from rima.exceptions import ( ResourceNotFoundError, ConflictError, MissingParameterError, UnknownError )#, FormatError, UnknownError # def debug(function): # @wraps(function) # def debug_wrapper(*args, **kwar...
{ "repo_name": "zoufou/rima", "path": "rima/decorators.py", "copies": "2", "size": "1534", "license": "apache-2.0", "hash": 9144341437423627000, "line_mean": 25, "line_max": 64, "alpha_frac": 0.5697522816, "autogenerated": false, "ratio": 4.272980501392758, "config_test": false, "has_no_keywor...
from functools import wraps from pprint import pprint import sys from flask import request, json from theroot.users_bundle.helpers.current_user_helper import CurrentUserHelper from theroot.users_bundle.helpers.users_and_roles import get_user_roles ''' This module provides a function decorator to use with your routing...
{ "repo_name": "Deviad/adhesive", "path": "theroot/users_bundle/helpers/router_acl.py", "copies": "1", "size": "5629", "license": "mit", "hash": -6972473347590904000, "line_mean": 42.6356589147, "line_max": 116, "alpha_frac": 0.506128975, "autogenerated": false, "ratio": 5.089511754068716, "conf...
from functools import wraps from .process_kwargs import process_kwargs def reducer_wrapper(process_data=None, defaults_process=None, defaults_data=None): def decorator(func): @wraps(func) def wrapper(argument, **kwargs): kwargs_process = {} kwargs_data = {} #: c...
{ "repo_name": "CKrawczyk/python-reducers-for-caesar", "path": "panoptes_aggregation/reducers/reducer_wrapper.py", "copies": "1", "size": "1161", "license": "apache-2.0", "hash": -7510491724142544000, "line_mean": 37.7, "line_max": 82, "alpha_frac": 0.5693367786, "autogenerated": false, "ratio": 4...
from functools import wraps from proso.func import function_name import inspect import logging import time import uuid LOGGER = logging.getLogger('django.request') TIMERS = {} def timer(name): now = time.time() diff = None if name in TIMERS: diff = now - TIMERS[name] TIMERS[name] = now r...
{ "repo_name": "adaptive-learning/proso-apps", "path": "proso/time.py", "copies": "1", "size": "1426", "license": "mit", "hash": 6036060935783767000, "line_mean": 27.52, "line_max": 173, "alpha_frac": 0.5694249649, "autogenerated": false, "ratio": 3.5472636815920398, "config_test": false, "has...
from functools import wraps from pymongo.cursor import Cursor as OrigCursor class Cursor(object): @classmethod def mk_list(cls, collection, o_cursor_list): return [cls(collection, o_cursor) for o_cursor in o_cursor_list] def __init__(self, collection, o_cursor): self.colle...
{ "repo_name": "CrowsT/MongoNorm", "path": "mongonorm/cursor.py", "copies": "1", "size": "1484", "license": "bsd-2-clause", "hash": 3844238688854816300, "line_mean": 28.0980392157, "line_max": 51, "alpha_frac": 0.5795148248, "autogenerated": false, "ratio": 3.89501312335958, "config_test": false...
from functools import wraps from pyramid.httpexceptions import HTTPBadRequest def assert_condition_returned(condition, error_message='', exception=HTTPBadRequest): ''' Decorator for checking return value of function. Results will be passed into condition function and error raised if True. ''' def ...
{ "repo_name": "ENCODE-DCC/snovault", "path": "src/snovault/elasticsearch/searches/decorators.py", "copies": "1", "size": "2730", "license": "mit", "hash": -6082921946280025000, "line_mean": 26.8571428571, "line_max": 85, "alpha_frac": 0.5732600733, "autogenerated": false, "ratio": 4.4901315789473...
from functools import wraps from pyramid.httpexceptions import ( HTTPMethodNotAllowed, HTTPForbidden, HTTPUnauthorized ) def not_allowed(self): raise HTTPMethodNotAllowed class View: def __init__(self, context, request): self.context = context self.request = request get = p...
{ "repo_name": "nthuion/nthuion-backend", "path": "nthuion/views/base.py", "copies": "1", "size": "2829", "license": "bsd-2-clause", "hash": -3369127834899454500, "line_mean": 26.2019230769, "line_max": 74, "alpha_frac": 0.5464828561, "autogenerated": false, "ratio": 4.6150081566068515, "config_...
from functools import wraps from pyramid.response import Response from .exceptions import (ValidationError, MissingFieldError, InvalidFieldValueError) import logging LOG = logging.getLogger(__name__) def validator(verify_func): """ Decorates a view function and perform per-view specific input validation. ...
{ "repo_name": "yeukhon/poll-app", "path": "pollapp/validation.py", "copies": "1", "size": "2460", "license": "mpl-2.0", "hash": 6925061680785272000, "line_mean": 31.3684210526, "line_max": 66, "alpha_frac": 0.6304878049, "autogenerated": false, "ratio": 4.416517055655296, "config_test": false, ...
from functools import wraps from pyrsistent._pmap import PMap, pmap from pyrsistent._pset import PSet, pset from pyrsistent._pvector import PVector, pvector def freeze(o, strict=True): """ Recursively convert simple Python containers into pyrsistent versions of those containers. - list is converted to...
{ "repo_name": "tobgu/pyrsistent", "path": "pyrsistent/_helpers.py", "copies": "1", "size": "3232", "license": "mit", "hash": -633271564277723000, "line_mean": 32.3195876289, "line_max": 102, "alpha_frac": 0.6417079208, "autogenerated": false, "ratio": 3.710677382319173, "config_test": false, ...
from functools import wraps from random import * from flask import render_template, flash, redirect, request, url_for, make_response from sqlalchemy import desc from sqlalchemy.exc import * from vuln_corp import app from vuln_corp import utils from vuln_corp.choices import ISSUE_ASSIGNEES from vuln_corp.forms import ...
{ "repo_name": "jeff350/vuln-corp", "path": "vuln_corp/views.py", "copies": "1", "size": "10866", "license": "mit", "hash": 4056743714003733000, "line_mean": 39.6966292135, "line_max": 119, "alpha_frac": 0.6156819437, "autogenerated": false, "ratio": 3.826056338028169, "config_test": false, "h...
from functools import wraps from redis import Redis class Redisns(object): key_commands = [ 'set', '__setitem__', 'get', '__getitem__', 'getset', 'incr', 'decr', ...
{ "repo_name": "rafacv/redisns", "path": "__init__.py", "copies": "1", "size": "2657", "license": "mit", "hash": 4534189385886975500, "line_mean": 33.0641025641, "line_max": 78, "alpha_frac": 0.3537824614, "autogenerated": false, "ratio": 5.080305927342256, "config_test": false, "has_no_keywor...
from functools import wraps from re import sub from flask import Blueprint, render_template, url_for, abort, g from flask.ext.admin import babel from flask.ext.admin._compat import with_metaclass from flask.ext.admin import helpers as h def expose(url='/', methods=('GET',)): """ Use this decorator to exp...
{ "repo_name": "wilsaj/flask-admin", "path": "flask_admin/base.py", "copies": "1", "size": "17990", "license": "bsd-3-clause", "hash": -8630699038251922000, "line_mean": 30.5614035088, "line_max": 126, "alpha_frac": 0.5423012785, "autogenerated": false, "ratio": 4.648578811369509, "config_test":...
from functools import wraps from re import sub from flask import Blueprint, render_template, url_for, abort, g from flask.ext.admin import babel from flask.ext.admin import helpers as h def expose(url='/', methods=('GET',)): """ Use this decorator to expose views in your view classes. :param url...
{ "repo_name": "0atman/flask-admin", "path": "flask_admin/base.py", "copies": "1", "size": "16041", "license": "bsd-3-clause", "hash": -8884900048795488000, "line_mean": 30.3913894325, "line_max": 123, "alpha_frac": 0.5356274546, "autogenerated": false, "ratio": 4.717941176470588, "config_test":...
from functools import wraps from robust.exception import (ContinuousFailureException, TimeoutException, ConnectionCutException) def _fail(ex, on_fail=None): if on_fail: on_fail() else: raise ex def retry(limit, on_fail=None): ""...
{ "repo_name": "zaibacu/pyRobustness", "path": "robust/tools.py", "copies": "1", "size": "2386", "license": "mit", "hash": 2859437107756931600, "line_mean": 24.9347826087, "line_max": 84, "alpha_frac": 0.526823135, "autogenerated": false, "ratio": 4.642023346303502, "config_test": false, "has_...
from functools import wraps from sample_data_utils.exception import MaxAttemptException def infinite(): """ auto inc generator """ i = 0 while 1: yield i i += 1 _sequence_counters = {} def sequence(prefix, cache=None): """ generator that returns an unique string ...
{ "repo_name": "saxix/sample-data-utils", "path": "sample_data_utils/utils.py", "copies": "1", "size": "2211", "license": "bsd-3-clause", "hash": 7710956275038409000, "line_mean": 21.11, "line_max": 79, "alpha_frac": 0.5694255993, "autogenerated": false, "ratio": 3.9063604240282683, "config_test...
from functools import wraps from sanic import response from sanic.request import Request from ssr_panel.models import User def login_required(f): @wraps(f) async def decorated_function(*args, **kwargs): for arg in args: if isinstance(arg, Request): uid = arg.get('session', ...
{ "repo_name": "gaolycn/ssr-panel-sanic", "path": "utils/decorators.py", "copies": "1", "size": "2262", "license": "mit", "hash": 8877623083269326000, "line_mean": 35.4838709677, "line_max": 93, "alpha_frac": 0.4991158267, "autogenerated": false, "ratio": 4.470355731225297, "config_test": false,...
from functools import wraps from sanic.response import json from sanic_redis import Namespace from App.model import User def captcha_check(_type): def decorator(func): @wraps(func) async def handler(request, *args, **kwargs): json_data = request.json if request.method == "GE...
{ "repo_name": "Basic-Components/auth-center", "path": "auth-center/App/decorator/captcha_check_dec.py", "copies": "1", "size": "1372", "license": "mit", "hash": -6694876689593031000, "line_mean": 42.9333333333, "line_max": 88, "alpha_frac": 0.5159332322, "autogenerated": false, "ratio": 4.1974522...
from functools import wraps from sanic.response import json from sanic_redis import Namespace from App.model import User,Role def authorized(): def decorator(func): @wraps(func) async def handler(request, *args, **kwargs): # Middleware goes here namespace = Namespace(request...
{ "repo_name": "Basic-Components/auth-center", "path": "auth-center/App/decorator/auth_check_dec.py", "copies": "1", "size": "1606", "license": "mit", "hash": -7064108630368697000, "line_mean": 39.1538461538, "line_max": 99, "alpha_frac": 0.4955300128, "autogenerated": false, "ratio": 4.6468842729...
from functools import wraps from ..selection import Selection, Interval from . import SelectModes def partial(func, *args, docs='', **keywords): """Pragmatic solution for being able to set a metadata for a partial function""" @wraps(func) def wrapper(*fargs, **fkeywords): newkeywords = keywords.cop...
{ "repo_name": "Chiel92/fate", "path": "fate/selecting/decorators.py", "copies": "1", "size": "2988", "license": "mit", "hash": 3399254944417939500, "line_mean": 32.2, "line_max": 90, "alpha_frac": 0.6161311914, "autogenerated": false, "ratio": 4.413589364844904, "config_test": false, "has_no_...
from functools import wraps from six.moves.urllib import parse from django.contrib.auth import REDIRECT_FIELD_NAME from django.contrib.auth.decorators import user_passes_test from django.shortcuts import render from django.contrib import messages from django.contrib.auth.views import redirect_to_login from django.core...
{ "repo_name": "marcoantoniooliveira/labweb", "path": "oscar/views/decorators.py", "copies": "1", "size": "4985", "license": "bsd-3-clause", "hash": 6807963652035719000, "line_mean": 38.88, "line_max": 79, "alpha_frac": 0.6702106319, "autogenerated": false, "ratio": 4.3235039028620985, "config_t...
from functools import wraps from six.moves.urllib.parse import urlparse import time import uuid from twisted.internet import defer """ Endpoints decorated with @trace will add an extra parameter, ctx. ctx needs to be down-propagated to all outgoing requests for request tracing. The @profile decorator provides additio...
{ "repo_name": "wrapp/txhttptrace", "path": "txhttptrace.py", "copies": "1", "size": "2940", "license": "mit", "hash": 3317605844120709000, "line_mean": 26.476635514, "line_max": 104, "alpha_frac": 0.6523809524, "autogenerated": false, "ratio": 3.93048128342246, "config_test": false, "has_no_k...
from functools import wraps from statsdecor import client def increment(name, tags=None): """Function decorator for incrementing a statsd stat whenever a function is invoked. >>> from statsdecor.decorators import increment >>> @increment('my.metric') >>> def my_func(): >>> pass """ ...
{ "repo_name": "freshbooks/statsdecor", "path": "statsdecor/decorators.py", "copies": "1", "size": "1547", "license": "mit", "hash": -2993586048445057500, "line_mean": 24.3606557377, "line_max": 65, "alpha_frac": 0.5617323853, "autogenerated": false, "ratio": 4.32122905027933, "config_test": fal...
from functools import wraps from string import ascii_lowercase from termcolor import cprint from twisted.internet import defer, reactor from rss.core import fetch commands = {} def command(name=None): def add_command(fn): commands[name or fn.__name__] = fn return fn return add_command def ...
{ "repo_name": "gwhitehawk/RSS", "path": "rss/script.py", "copies": "1", "size": "1233", "license": "mit", "hash": 178001663963536540, "line_mean": 18.8870967742, "line_max": 74, "alpha_frac": 0.6561232766, "autogenerated": false, "ratio": 3.926751592356688, "config_test": false, "has_no_keywo...
from functools import wraps from string import digits from pyvi.mode import Mode from pyvi.modes import insert def motion(fn): @wraps(fn) def move(editor): cursor = editor.active_window.cursor moved_to = fn(editor, count=editor.count or 1) # XXX: do this on any executed command ...
{ "repo_name": "Julian/PyVi", "path": "pyvi/modes/_normal.py", "copies": "1", "size": "1990", "license": "mit", "hash": -6219647325813957000, "line_mean": 20.8681318681, "line_max": 62, "alpha_frac": 0.6261306533, "autogenerated": false, "ratio": 3.5535714285714284, "config_test": false, "has_...
from functools import wraps from StringIO import StringIO # No need for cStringIO at this time import sys def mock_streams(*which): """ Replaces a stream with a ``StringIO`` during the test, then restores after. Must specify which stream (stdout, stderr, etc) via string args, e.g.:: @mock_stream...
{ "repo_name": "simon-engledew/fabric", "path": "tests/utils.py", "copies": "1", "size": "1105", "license": "bsd-2-clause", "hash": -2439784212568234000, "line_mean": 28.0789473684, "line_max": 79, "alpha_frac": 0.5511312217, "autogenerated": false, "ratio": 4.455645161290323, "config_test": fal...
from functools import wraps from sys import getsizeof from typing import ( TYPE_CHECKING, Any, Callable, Hashable, Iterable, List, Optional, Sequence, Tuple, Union, ) import warnings import numpy as np from pandas._config import get_option from pandas._libs import algos as lib...
{ "repo_name": "rs2/pandas", "path": "pandas/core/indexes/multi.py", "copies": "1", "size": "127449", "license": "bsd-3-clause", "hash": 3405361719005851600, "line_mean": 32.5833992095, "line_max": 88, "alpha_frac": 0.5209770183, "autogenerated": false, "ratio": 4.355295082527424, "config_test":...
from functools import wraps from threading import local from .models import Revision from .utils import obj_diff, obj_is_changed class Transaction(object): def __init__(self,): """Constructor of Transaction instance.""" self.ctx = local() @property def scopes(self): """Get transa...
{ "repo_name": "luzfcb/django-versioning", "path": "versioning/transaction.py", "copies": "1", "size": "3079", "license": "bsd-3-clause", "hash": -1988440609296181200, "line_mean": 24.6583333333, "line_max": 69, "alpha_frac": 0.5073075674, "autogenerated": false, "ratio": 4.235213204951857, "con...
from functools import wraps from threading import Lock, Event from weakref import WeakValueDictionary from os import walk from os import curdir from os import listdir from os import makedirs from os import unlink from os.path import relpath from os.path import join from os.path import abspath from os.path import exists...
{ "repo_name": "ssorgatem/pulsar", "path": "pulsar/client/util.py", "copies": "1", "size": "8569", "license": "apache-2.0", "hash": -8727887246279321000, "line_mean": 29.4946619217, "line_max": 119, "alpha_frac": 0.6140739876, "autogenerated": false, "ratio": 3.669807280513919, "config_test": fa...
from functools import wraps from threading import Lock import logging __all__ = [ 'Speedometer', ] class Speedometer(object): logger = logging.getLogger('speedometer') def __init__(self, metric, debug=__debug__): self.metric = metric self._lock = Lock() self.debug = debug d...
{ "repo_name": "minmax/python-speedometer", "path": "speedometer/speedometer.py", "copies": "1", "size": "1585", "license": "unlicense", "hash": 5217181700408366000, "line_mean": 25.8644067797, "line_max": 60, "alpha_frac": 0.5438485804, "autogenerated": false, "ratio": 4.439775910364146, "confi...
from functools import wraps from threading import RLock from collections import defaultdict class AlreadyRunningError(Exception): pass def try_lock(keyfn=None): '''Allow function to run only once. `keyfn` can be used to select a subset of the function arguments/kwargs to lock on. Will raise `Already...
{ "repo_name": "tebeka/pythonwise", "path": "trylock.py", "copies": "1", "size": "1255", "license": "bsd-3-clause", "hash": -5518853996895444000, "line_mean": 25.7021276596, "line_max": 78, "alpha_frac": 0.5689243028, "autogenerated": false, "ratio": 4.327586206896552, "config_test": false, "h...
from functools import wraps from threading import Thread from app import render_template, redirect, url_for, request, session, flash, Markup # decorators def login_required(f): @wraps(f) def wrap(*args, **kwargs): if 'logged_in' in session: return f(*args, **kwargs) else: flash('You need to log in first.'...
{ "repo_name": "abmorton/stockhawk", "path": "decorators.py", "copies": "1", "size": "1826", "license": "mit", "hash": -4874174813102836000, "line_mean": 28.4516129032, "line_max": 223, "alpha_frac": 0.6549835706, "autogenerated": false, "ratio": 3.0844594594594597, "config_test": false, "has_...
from functools import wraps from threading import Thread def before(f, chain=False): """Runs f before the decorated function.""" def decorator(g): @wraps(g) def h(*args, **kargs): if chain: return g(f(*args, **kargs)) else: f(*args, **kar...
{ "repo_name": "astex/sequential", "path": "sequential/decorators.py", "copies": "1", "size": "1148", "license": "mit", "hash": -3097837276728778000, "line_mean": 24.5111111111, "line_max": 80, "alpha_frac": 0.4912891986, "autogenerated": false, "ratio": 4.2518518518518515, "config_test": false,...
from functools import wraps from threepio import logger from django.utils import timezone from rest_framework import exceptions, status from rest_framework.decorators import detail_route from rest_framework.exceptions import ValidationError from rest_framework.response import Response from rest_framework.viewsets impo...
{ "repo_name": "CCI-MOC/GUI-Backend", "path": "api/v2/views/base.py", "copies": "1", "size": "12075", "license": "apache-2.0", "hash": 6240476827036305000, "line_mean": 36.734375, "line_max": 220, "alpha_frac": 0.5897308489, "autogenerated": false, "ratio": 4.683863460046548, "config_test": fals...
from functools import wraps from time import sleep from mydjangoapp.celeryconf import app from .models import Job from .messagequeue import send_msg from .redisconf import redis_conn def update_job(fn): @wraps(fn) def wrapper(job_id, *args, **kwargs): job = Job.objects.get(id=job_id) job.stat...
{ "repo_name": "wenxinwilliam/docker-django-celery", "path": "mydjangoapp/mydjangoapp/tasks.py", "copies": "1", "size": "1474", "license": "mit", "hash": -6299101498262889000, "line_mean": 18.4078947368, "line_max": 86, "alpha_frac": 0.5664857531, "autogenerated": false, "ratio": 3.239560439560439...
from functools import wraps from time import sleep import capybara from capybara.exceptions import ElementNotFound, FrozenInTime, ScopeError from capybara.helpers import Timer from capybara.node.actions import ActionsMixin from capybara.node.finders import FindersMixin from capybara.node.matchers import MatchersMixin ...
{ "repo_name": "elliterate/capybara.py", "path": "capybara/node/base.py", "copies": "1", "size": "7848", "license": "mit", "hash": 7362634739936522000, "line_mean": 35.5023255814, "line_max": 100, "alpha_frac": 0.5819317023, "autogenerated": false, "ratio": 4.753482737734706, "config_test": fals...
from functools import wraps from time import time as now from flask import make_response from mmmpaste import app def runtime(fn): """ Add a header that shows the runtime of the route. """ @wraps(fn) def wrapper(*args, **kwargs): start = now() response = make_response(fn(*args, **...
{ "repo_name": "ryanc/mmmpaste", "path": "mmmpaste/filters.py", "copies": "1", "size": "1030", "license": "bsd-2-clause", "hash": -1487712607201435100, "line_mean": 22.9534883721, "line_max": 74, "alpha_frac": 0.6009708738, "autogenerated": false, "ratio": 3.7050359712230216, "config_test": fals...
from functools import wraps from time import time from datetime import timedelta import Queue class CancelJobException(Exception): pass class ProgressSection(object): def __init__(self, name): self.name = name self.size = 100 self.progress = 0 self.on_change = None s...
{ "repo_name": "greginvm/grslicer", "path": "grslicer/util/progress.py", "copies": "1", "size": "3601", "license": "mit", "hash": 4318803607644221400, "line_mean": 24.3591549296, "line_max": 105, "alpha_frac": 0.5942793668, "autogenerated": false, "ratio": 4.129587155963303, "config_test": false...
from functools import wraps from time import time from txmongo.errors import TimeExceeded from twisted.internet import defer, reactor def timeout(func): """Decorator to add timeout to Deferred calls""" @wraps(func) def _timeout(*args, **kwargs): now = time() deadline = kwargs.pop("deadlin...
{ "repo_name": "twisted/txmongo", "path": "txmongo/utils/__init__.py", "copies": "1", "size": "2034", "license": "apache-2.0", "hash": 3253722569089378300, "line_mean": 30.78125, "line_max": 105, "alpha_frac": 0.6032448378, "autogenerated": false, "ratio": 4.211180124223603, "config_test": false...
from functools import wraps from time import time from atomic import AtomicLong from metrology.stats import EWMA from metrology.utils import now def ticker(method): @wraps(method) def wrapper(self, *args, **kwargs): self._tick() return method(self, *args, **kwargs) return wrapper class...
{ "repo_name": "cyberdelia/metrology", "path": "metrology/instruments/meter.py", "copies": "1", "size": "3172", "license": "mit", "hash": -2038951368017522700, "line_mean": 24.7886178862, "line_max": 79, "alpha_frac": 0.5703026482, "autogenerated": false, "ratio": 3.723004694835681, "config_test...
from functools import wraps from time import time from atomic import Atomic from metrology.stats import EWMA def ticker(method): @wraps(method) def wrapper(self, *args, **kwargs): self._tick() return method(self, *args, **kwargs) return wrapper class Meter(object): """A meter measu...
{ "repo_name": "zenoss/metrology", "path": "metrology/instruments/meter.py", "copies": "1", "size": "2734", "license": "mit", "hash": -6441167025395991000, "line_mean": 25.8039215686, "line_max": 91, "alpha_frac": 0.5881492319, "autogenerated": false, "ratio": 3.6550802139037435, "config_test": ...
from functools import wraps from time import time from django_statsd.clients import statsd class UnauthorizedException(Exception): """Failure to log into the email server.""" pass class NewsletterException(Exception): """Error when trying to talk to the the email server.""" def __init__(self, msg=...
{ "repo_name": "glogiotatidis/basket", "path": "basket/news/backends/common.py", "copies": "1", "size": "1500", "license": "mpl-2.0", "hash": -2446390408270450700, "line_mean": 25.7857142857, "line_max": 82, "alpha_frac": 0.586, "autogenerated": false, "ratio": 4.451038575667655, "config_test": ...
from functools import wraps from time import time from flask import request, g, Response, session, jsonify import redis __author__ = "David Lawrence" __copyright__ = "Copyright 2015, David Lawrence" __credits__ = ["David Lawrence"] __license__ = "MIT" __version__ = "0.1" __maintainer__ = "David Lawrence" __email__ = ...
{ "repo_name": "Hellorin/gaming-challenges-api", "path": "fdk/apps/gaming_challenges/controllers/api/utils.py", "copies": "1", "size": "2421", "license": "mit", "hash": -8968448866598390000, "line_mean": 25.3152173913, "line_max": 65, "alpha_frac": 0.5159025196, "autogenerated": false, "ratio": 4....
from functools import wraps from time import time import collections class RateLimitExceeded(Exception): pass class TokenBucket(object): """An implementation of the token bucket algorithm. >>> bucket = TokenBucket(80, 0.5) >>> print bucket.consume(10) True >>> print bucket.consume(90) ...
{ "repo_name": "sk89q/Plumeria", "path": "plumeria/util/ratelimit.py", "copies": "1", "size": "3180", "license": "mit", "hash": -5318379132595142000, "line_mean": 32.125, "line_max": 106, "alpha_frac": 0.5883647799, "autogenerated": false, "ratio": 4.350205198358413, "config_test": false, "has...
from functools import wraps from time import time, sleep import warnings import sys # for verbose exception information from inspect import getargspec def stringified_warnings(warn_list): return [str(w) for w in warn_list] def meta_func(ignore_errors=False): _LogInfoDict = dict() def decorating_function(user_funct...
{ "repo_name": "gstaubli/meta_func", "path": "meta_func/meta_func.py", "copies": "1", "size": "1466", "license": "mit", "hash": 396362320809397900, "line_mean": 34.7804878049, "line_max": 121, "alpha_frac": 0.7039563438, "autogenerated": false, "ratio": 3.2723214285714284, "config_test": false, ...
from functools import wraps from transmute_core.exceptions import APIException, NoSerializerFound from transmute_core.function.signature import NoDefault from transmute_core import ParamExtractor, NoArgument from sanic.response import HTTPResponse from sanic.exceptions import SanicException DEFAULT_HTTP_CONTENT_TYPE ...
{ "repo_name": "yunstanford/sanic-transmute", "path": "sanic_transmute/handler.py", "copies": "1", "size": "2457", "license": "mit", "hash": -91322083733984720, "line_mean": 31.3289473684, "line_max": 85, "alpha_frac": 0.6402116402, "autogenerated": false, "ratio": 4.136363636363637, "config_tes...
from functools import wraps from tryhaskell import TryHaskell from helga.plugins import command def clean_output(f): @wraps(f) def wrapper(*args, **kwargs): try: result = f(*args, **kwargs) except TryHaskell.Error as e: result = 'Uh oh: ' + e.message # Truncate ...
{ "repo_name": "carymrobbins/helga-haskell", "path": "helga_haskell.py", "copies": "1", "size": "1471", "license": "bsd-3-clause", "hash": 5710476609196519000, "line_mean": 30.9782608696, "line_max": 82, "alpha_frac": 0.6240652617, "autogenerated": false, "ratio": 3.5965770171149143, "config_tes...
from functools import wraps from types import FunctionType from typing import Generator, Callable, Iterable, overload def filled_iter(iter, filler): """Inbetween every iteration, yield a constant filler.""" first = True for elem in iter: if not first: yield filler else: ...
{ "repo_name": "lukasjuhrich/pycroft", "path": "web/blueprints/helpers/lazy_join.py", "copies": "1", "size": "2295", "license": "apache-2.0", "hash": 6513167815679903000, "line_mean": 28.8051948052, "line_max": 82, "alpha_frac": 0.6222222222, "autogenerated": false, "ratio": 3.768472906403941, "...
from functools import wraps from types import MethodType from sys import version_info if version_info < (3, 0, 0): from inspect import getargspec else: from inspect import getfullargspec as getargspec try: from collections.abc import Callable except ImportError: from collections import Callable from py...
{ "repo_name": "uzumaxy/pyvalid", "path": "pyvalid/__accepts.py", "copies": "1", "size": "8488", "license": "bsd-3-clause", "hash": 4001766825676435000, "line_mean": 37.3529411765, "line_max": 88, "alpha_frac": 0.5657149599, "autogenerated": false, "ratio": 4.547210300429184, "config_test": fals...
from functools import wraps from types import MethodType from typing import Any, Callable, Iterable, Union import simpy from desmod.pool import Pool from desmod.queue import ItemType, Queue ProbeCallback = Callable[[Any], None] ProbeCallbacks = Iterable[ProbeCallback] ProbeTarget = Union[ Pool, Queue[ItemType], ...
{ "repo_name": "SanDisk-Open-Source/desmod", "path": "desmod/probe.py", "copies": "1", "size": "5146", "license": "mit", "hash": -8329293910590438000, "line_mean": 30.7654320988, "line_max": 88, "alpha_frac": 0.6129032258, "autogenerated": false, "ratio": 4.017174082747853, "config_test": false,...
from functools import wraps from types import MethodType from django.conf import settings from django.db import connections from django_perf_rec.orm import patch_ORM_to_be_deterministic from django_perf_rec.settings import perf_rec_settings from django_perf_rec.sql import sql_fingerprint from django_perf_rec.utils im...
{ "repo_name": "YPlan/django-perf-rec", "path": "src/django_perf_rec/db.py", "copies": "1", "size": "2980", "license": "mit", "hash": -3930953546372278000, "line_mean": 29.4081632653, "line_max": 88, "alpha_frac": 0.6006711409, "autogenerated": false, "ratio": 4.185393258426966, "config_test": f...
from functools import wraps from types import MethodType try: from collections.abc import Callable except ImportError: from collections import Callable from pyvalid.__exceptions import InvalidReturnTypeError from pyvalid.switch import is_enabled class Returns(Callable): """ ``pyvalid.returns(*allowed...
{ "repo_name": "uzumaxy/pyvalid", "path": "pyvalid/__returns.py", "copies": "1", "size": "2941", "license": "bsd-3-clause", "hash": 3237704383247602700, "line_mean": 35.2592592593, "line_max": 86, "alpha_frac": 0.5658835546, "autogenerated": false, "ratio": 4.903171953255426, "config_test": fals...
from functools import wraps from typing import Any, Callable, Dict, Mapping, Set, Tuple, Union, cast from django.http import HttpRequest, HttpResponse from django.urls import path from django.urls.resolvers import URLPattern from django.utils.cache import add_never_cache_headers from django.views.decorators.csrf impor...
{ "repo_name": "kou/zulip", "path": "zerver/lib/rest.py", "copies": "2", "size": "7717", "license": "apache-2.0", "hash": 9183327914192949000, "line_mean": 44.6627218935, "line_max": 102, "alpha_frac": 0.6665802773, "autogenerated": false, "ratio": 4.335393258426966, "config_test": false, "has...
from functools import wraps from typing import Any, Callable, Dict from django.conf import settings from django.http import HttpRequest, HttpResponse, HttpResponseRedirect from django.utils.cache import add_never_cache_headers from django.utils.module_loading import import_string from django.views.decorators.csrf impo...
{ "repo_name": "shubhamdhama/zulip", "path": "zerver/lib/rest.py", "copies": "1", "size": "8088", "license": "apache-2.0", "hash": -196735808177406400, "line_mean": 46.023255814, "line_max": 133, "alpha_frac": 0.65628091, "autogenerated": false, "ratio": 4.369529983792544, "config_test": false, ...
from functools import wraps from typing import Any, Callable, Dict from django.utils.module_loading import import_string from django.utils.translation import ugettext as _ from django.utils.cache import add_never_cache_headers from django.views.decorators.csrf import csrf_exempt, csrf_protect from zerver.decorator im...
{ "repo_name": "rht/zulip", "path": "zerver/lib/rest.py", "copies": "1", "size": "8524", "license": "apache-2.0", "hash": -3153767207414811600, "line_mean": 48.5581395349, "line_max": 123, "alpha_frac": 0.6613092445, "autogenerated": false, "ratio": 4.405167958656331, "config_test": false, "ha...
from functools import wraps from typing import Any, Callable, Dict, Optional, cast from unittest import mock import orjson from django.conf import settings from django.test import override_settings from zerver.lib.actions import do_create_user, get_service_bot_events from zerver.lib.bot_config import ConfigError, loa...
{ "repo_name": "kou/zulip", "path": "zerver/tests/test_service_bot_system.py", "copies": "3", "size": "23393", "license": "apache-2.0", "hash": -8525752146779063000, "line_mean": 43.1377358491, "line_max": 130, "alpha_frac": 0.5945795751, "autogenerated": false, "ratio": 3.9974367737525633, "con...
from functools import wraps from typing import Any, Callable, Dict, Optional, TypeVar, cast from unittest import mock import orjson from django.conf import settings from django.test import override_settings from zerver.lib.actions import do_create_user, get_service_bot_events from zerver.lib.bot_config import ConfigE...
{ "repo_name": "punchagan/zulip", "path": "zerver/tests/test_service_bot_system.py", "copies": "3", "size": "22938", "license": "apache-2.0", "hash": 643411342700230800, "line_mean": 39.0314136126, "line_max": 99, "alpha_frac": 0.6124771122, "autogenerated": false, "ratio": 3.846076458752515, "c...
from functools import wraps from typing import Any, Callable from warnings import warn raise NotImplementedError(""" This module worked, almost, and then I broke it in an attempt to make it better. Don't use. """) def _first_arg(*args, **kwargs): if len(args) > 0: return args[0] else: try: ...
{ "repo_name": "thorwhalen/ut", "path": "errors.py", "copies": "1", "size": "7899", "license": "mit", "hash": -2761587804590433300, "line_mean": 27.6195652174, "line_max": 101, "alpha_frac": 0.6027345234, "autogenerated": false, "ratio": 3.8607038123167157, "config_test": false, "has_no_keywor...
from functools import wraps from typing import Any, Dict, cast from django.conf import settings from django.http import HttpRequest, HttpResponse, HttpResponseRedirect from django.utils.cache import add_never_cache_headers from django.utils.module_loading import import_string from django.views.decorators.csrf import c...
{ "repo_name": "synicalsyntax/zulip", "path": "zerver/lib/rest.py", "copies": "2", "size": "8029", "license": "apache-2.0", "hash": 8468365019141807000, "line_mean": 46.2294117647, "line_max": 102, "alpha_frac": 0.6601071117, "autogenerated": false, "ratio": 4.342347214710655, "config_test": fal...
from functools import wraps from typing import Callable, Any, TypeVar from threading import Lock from collections import defaultdict import datetime T = TypeVar("T") def lazy(method: Callable[[Any], T]) -> Callable[[Any], T]: @wraps(method) def wrapper(self) -> T: s = "_lazy__{}".format(method.__name...
{ "repo_name": "meraki-analytics/merakicommons", "path": "merakicommons/cache.py", "copies": "2", "size": "2876", "license": "mit", "hash": -1832020175033381400, "line_mean": 28.0505050505, "line_max": 81, "alpha_frac": 0.5236439499, "autogenerated": false, "ratio": 4.126255380200861, "config_te...
from functools import wraps from typing import Callable from demisto_sdk.commands.test_content.mock_server import MITMProxy def run_with_proxy_configured(function: Callable) -> Callable: """ This is a decorator for the 'instance_testing method`. This decorator configures the proxy in the server before th...
{ "repo_name": "demisto/content", "path": "Tests/tools.py", "copies": "1", "size": "1195", "license": "mit", "hash": 5155368866135028000, "line_mean": 44.9615384615, "line_max": 118, "alpha_frac": 0.6108786611, "autogenerated": false, "ratio": 4.631782945736434, "config_test": false, "has_no_k...
from functools import wraps from typing import Callable from flask import abort, g, redirect, request, url_for from . import app from .models import Assignment from .viewmodel import get_source_repos def login_required(f: Callable): """A view function decorator that requires the user is logged in.""" if not...
{ "repo_name": "osteele/assignment-dashboard", "path": "assignment_dashboard/decorators.py", "copies": "2", "size": "1992", "license": "mit", "hash": -6422927633233379000, "line_mean": 30.619047619, "line_max": 101, "alpha_frac": 0.6345381526, "autogenerated": false, "ratio": 4.024242424242424, ...
from functools import wraps from typing import Callable from .. import uwsgi class Lock: """Locks related stuff. Lock number 0 is always available. More locks need to be registered with ``.config.locking.set_basic_params(count=X)`` where ``X`` is the number of locks. .. note:: The same lock should ...
{ "repo_name": "idlesign/uwsgiconf", "path": "uwsgiconf/runtime/locking.py", "copies": "1", "size": "1772", "license": "bsd-3-clause", "hash": -6261080978706902000, "line_mean": 19.367816092, "line_max": 90, "alpha_frac": 0.5485327314, "autogenerated": false, "ratio": 4.219047619047619, "config_...
from functools import wraps from typing import Callable from .. import uwsgi stop = uwsgi.stop reload = uwsgi.reload disconnect = uwsgi.disconnect set_process_name = uwsgi.setprocname class harakiri_imposed: """Decorator and context manager. Allows temporarily setting harakiri timeout for a function or ...
{ "repo_name": "idlesign/uwsgiconf", "path": "uwsgiconf/runtime/control.py", "copies": "1", "size": "1294", "license": "bsd-3-clause", "hash": -2147119245782430500, "line_mean": 18.9076923077, "line_max": 79, "alpha_frac": 0.5610510046, "autogenerated": false, "ratio": 3.874251497005988, "config...
from functools import wraps from typing import Dict, Optional, Union import jembatan.core.spandex as spandex def process_default_view(f): """ For single-view analysis functions it's often easier to define manipulations in terms of the view/spandex object instead of having to get the view from the parent j...
{ "repo_name": "leebecker/jembatan", "path": "jembatan/core/af/__init__.py", "copies": "1", "size": "5767", "license": "apache-2.0", "hash": 7696643039530299000, "line_mean": 40.1928571429, "line_max": 115, "alpha_frac": 0.6608288538, "autogenerated": false, "ratio": 4.382218844984802, "config_t...
from functools import wraps from typing import List, Mapping, Union, Any from django.http import QueryDict, HttpResponseNotAllowed from django.utils.decorators import available_attrs from util.strutils import TemplateString def make_querydict_from_request(func): @wraps(func, assigned=available_attrs(func)) d...
{ "repo_name": "FRC-RS/FRS", "path": "util/viewutils.py", "copies": "1", "size": "5464", "license": "mit", "hash": 9061427298883531000, "line_mean": 41.6875, "line_max": 125, "alpha_frac": 0.6740483163, "autogenerated": false, "ratio": 4.367705835331734, "config_test": false, "has_no_keywords"...
from functools import wraps from typing import List, TypeVar, Callable, Tuple, Dict from typing import Optional from genes.lib.logging import log_warn, log_error from genes.lib.traits import ErrorLevel from genes.linux.traits import get_distro, get_version, get_codename T = TypeVar('T') def is_alpine(versions: Opti...
{ "repo_name": "hatchery/Genepool2", "path": "genes/alpine/traits.py", "copies": "2", "size": "1277", "license": "mit", "hash": -3853007189620068400, "line_mean": 32.6052631579, "line_max": 97, "alpha_frac": 0.6217697729, "autogenerated": false, "ratio": 3.8119402985074626, "config_test": false,...
from functools import wraps from typing import * from uuid import uuid4 as uuid import observable from pros.common import logger _uuid_table = dict() # type: Dict[str, Observable] class Observable(observable.Observable): """ Wrapper class for the observable package for use in interactive UI. It registers ...
{ "repo_name": "purduesigbots/pros-cli", "path": "pros/common/ui/interactive/observable.py", "copies": "1", "size": "3113", "license": "mpl-2.0", "hash": -3671372661175734000, "line_mean": 38.9102564103, "line_max": 118, "alpha_frac": 0.5772566656, "autogenerated": false, "ratio": 4.35994397759103...
from functools import wraps from typing import * from couchbase_core.supportability import internal from .options import Cardinal, OptionBlock, OptionBlockTimeOut from couchbase_core.durability import Durability from datetime import timedelta try: from typing import TypedDict except: from typing_extensions i...
{ "repo_name": "couchbase/couchbase-python-client", "path": "couchbase/durability.py", "copies": "1", "size": "4102", "license": "apache-2.0", "hash": 8544462539466757000, "line_mean": 31.816, "line_max": 122, "alpha_frac": 0.6133593369, "autogenerated": false, "ratio": 4.259605399792315, "confi...
from functools import wraps from unittest import mock from django.contrib.auth.models import User from django.test.testcases import TestCase from django.urls.base import reverse from builds.factories import ProjectFactory def authenticated_test_case(f): @wraps(f) def inner(self, *args, **kwargs): se...
{ "repo_name": "karamanolev/persephone", "path": "persephone/builds/tests/test_views.py", "copies": "1", "size": "1163", "license": "mit", "hash": -9179468938144267000, "line_mean": 27.3658536585, "line_max": 86, "alpha_frac": 0.6474634566, "autogenerated": false, "ratio": 3.8131147540983608, "c...
#from functools import wraps from unittest import TestCase from IPython import embed import numpy as np from peewee import * from playhouse.postgres_ext import * db = PostgresqlExtDatabase(database='gkdb_test') db.execute_sql('CREATE EXTENSION IF NOT EXISTS hstore;') db.execute_sql('CREATE SCHEMA IF NOT EXISTS develop...
{ "repo_name": "gkdb/gkdb", "path": "tests/gkdb/core/base.py", "copies": "1", "size": "3226", "license": "mit", "hash": 4781914000479231000, "line_mean": 30.9405940594, "line_max": 90, "alpha_frac": 0.6171729696, "autogenerated": false, "ratio": 4.173350582147477, "config_test": true, "has_no_...
from functools import wraps from unittest import TestCase import warnings from django.contrib.admin.views.decorators import staff_member_required from django.contrib.auth.decorators import login_required, permission_required, user_passes_test from django.http import HttpResponse, HttpRequest, HttpResponseNotAllowed fr...
{ "repo_name": "yceruto/django", "path": "tests/decorators/tests.py", "copies": "6", "size": "8387", "license": "bsd-3-clause", "hash": -665177422646794600, "line_mean": 31.3822393822, "line_max": 118, "alpha_frac": 0.6457612972, "autogenerated": false, "ratio": 4.077297034516286, "config_test":...
from functools import wraps from urllib.error import URLError from django.db import models from django.urls import reverse #from amazonproduct import API as AmazonAPI from manabi.apps.utils.slugs import slugify from django.conf import settings #TODO-OLD find different way. #amazon_api = AmazonAPI(settings.AWS_KEY, ...
{ "repo_name": "aehlke/manabi", "path": "manabi/apps/books/models.py", "copies": "1", "size": "3146", "license": "mit", "hash": 1971736059722793700, "line_mean": 28.1296296296, "line_max": 83, "alpha_frac": 0.5890019072, "autogenerated": false, "ratio": 3.8087167070217918, "config_test": false, ...
from functools import wraps from urllib.request import Request, urlopen, quote from flask import Blueprint, g, render_template, request, flash from flask_login import login_required, current_user from app.models import ROLE_ADMIN from app.forms import SendSMSForm from app import app admin_module = Blueprint('admin', ...
{ "repo_name": "Kwentar/Dream-Crusher", "path": "app/admin_views.py", "copies": "1", "size": "4030", "license": "apache-2.0", "hash": -1045146840305112800, "line_mean": 37.2857142857, "line_max": 111, "alpha_frac": 0.6582711443, "autogenerated": false, "ratio": 2.2042494859492803, "config_test":...
from functools import wraps from urlparse import urlparse from django.conf import settings from django.contrib.auth import REDIRECT_FIELD_NAME from django.shortcuts import resolve_url from django.utils.decorators import available_attrs from django.utils.encoding import force_str from django.utils.functional import curr...
{ "repo_name": "ministryofjustice/cla_frontend", "path": "cla_frontend/apps/cla_auth/utils.py", "copies": "1", "size": "2950", "license": "mit", "hash": 4408250030441393700, "line_mean": 35.875, "line_max": 101, "alpha_frac": 0.6610169492, "autogenerated": false, "ratio": 4.002713704206242, "con...
from functools import wraps from util.commons_util.logger.Timer import Timer __author__ = 'Danyang' def timestamp(func): """ time the execution time of a function :param func: the function, whose result you would like to cached based on input arguments """ def ret(*args): timer = Timer()...
{ "repo_name": "idf/commons-util-py", "path": "commons_util/decorators/general.py", "copies": "1", "size": "1699", "license": "apache-2.0", "hash": 500218525816812200, "line_mean": 24.3582089552, "line_max": 104, "alpha_frac": 0.6156562684, "autogenerated": false, "ratio": 4.268844221105527, "co...
from functools import wraps from Utils import * def do(monad): """An implementation of Haskell's do-notation, using generators. Do-notation in Haskell looks like this: m = do x <- a y <- b pure (x, y) This implementation in Python looks like this: @do(Monad) ...
{ "repo_name": "oisdk/PyParse", "path": "Do.py", "copies": "1", "size": "1031", "license": "mit", "hash": 555623947036213800, "line_mean": 29.3235294118, "line_max": 68, "alpha_frac": 0.490785645, "autogenerated": false, "ratio": 4.260330578512397, "config_test": false, "has_no_keywords": fals...
from functools import wraps from uuid import uuid1 from codenode.external.jsonrpc._json import loads, dumps from codenode.external.jsonrpc.exceptions import * from codenode.external.jsonrpc.types import * empty_dec = lambda f: f try: from django.views.decorators.csrf import csrf_exempt except (NameError, ImportError)...
{ "repo_name": "regmi/codenode-unr", "path": "codenode/external/jsonrpc/site.py", "copies": "1", "size": "8195", "license": "bsd-3-clause", "hash": -977998780124975600, "line_mean": 32.7242798354, "line_max": 98, "alpha_frac": 0.5954850519, "autogenerated": false, "ratio": 3.6085424922941436, "c...
from functools import wraps from uuid import uuid1 from types import NoneType from django.http import HttpResponse from jsonrpc._json import loads, dumps from jsonrpc.exceptions import * empty_dec = lambda f: f try: from django.views.decorators.csrf import csrf_exempt except (NameError, ImportError): csrf_exempt = ...
{ "repo_name": "edisonlz/fruit", "path": "web_project/base/site-packages/jsonrpc/site.py", "copies": "1", "size": "6821", "license": "apache-2.0", "hash": -2980159656906120700, "line_mean": 31.327014218, "line_max": 98, "alpha_frac": 0.5837853687, "autogenerated": false, "ratio": 3.689021092482423...
from functools import wraps from uuid import uuid4 from ascetic import interfaces, utils class BaseTransaction(interfaces.ITransaction): def __init__(self, db_accessor): self._db = db_accessor def parent(self): return None def can_reconnect(self): return False def set_autoco...
{ "repo_name": "emacsway/ascetic", "path": "ascetic/transaction.py", "copies": "1", "size": "3687", "license": "mit", "hash": 8871807221768578000, "line_mean": 23.2565789474, "line_max": 82, "alpha_frac": 0.5725522105, "autogenerated": false, "ratio": 4.332549941245594, "config_test": false, "...
from functools import wraps from uuid import uuid4 from app.globals import get_session_store from app.utilities.schema import load_schema_from_session_data def with_schema(function): """Adds the survey schema as the first argument to the function being wrapped. Use on flask request handlers or methods called...
{ "repo_name": "ONSdigital/eq-survey-runner", "path": "app/helpers/schema_helpers.py", "copies": "1", "size": "4296", "license": "mit", "hash": 7786325956239812000, "line_mean": 40.7087378641, "line_max": 120, "alpha_frac": 0.697858473, "autogenerated": false, "ratio": 3.732406602953953, "config...
from functools import wraps from uuid import UUID from ipware.ip import get_ip from django.conf import settings from django.contrib.auth import REDIRECT_FIELD_NAME from django.utils.decorators import available_attrs from django.utils.six.moves.urllib.parse import urlparse from django.shortcuts import resolve_url, redi...
{ "repo_name": "gcrahay/fir_irma_plugin", "path": "fir_irma/decorators.py", "copies": "1", "size": "4916", "license": "apache-2.0", "hash": 1218710751414903000, "line_mean": 49.1632653061, "line_max": 114, "alpha_frac": 0.5921480879, "autogenerated": false, "ratio": 4.201709401709402, "config_te...
from functools import wraps from voluptuous import Schema, Required, Any, All, Length, Range def validate_input(function): """Decorator that validates the kwargs of the function passed to it.""" @wraps(function) def wrapper(*args, **kwargs): try: name = function.__name__ + '_validator'...
{ "repo_name": "mcash/merchant-api-python-sdk", "path": "mcash/mapi_client/validation.py", "copies": "1", "size": "5048", "license": "mit", "hash": 3893830095458989600, "line_mean": 30.748427673, "line_max": 101, "alpha_frac": 0.6109350238, "autogenerated": false, "ratio": 4.100731112916328, "co...
from functools import wraps from weakref import WeakValueDictionary, ref from contextlib import contextmanager from blinker import Signal from ..exceptions import Cancel class LockedSignal(Signal): _lock = None def _locked_super_method(self, name, *args, **kwargs): try: if self._lock: ...
{ "repo_name": "denz/swarm", "path": "swarm/signals/base.py", "copies": "1", "size": "2800", "license": "bsd-3-clause", "hash": 2673548018904386600, "line_mean": 27.01, "line_max": 80, "alpha_frac": 0.5864285714, "autogenerated": false, "ratio": 4.2682926829268295, "config_test": false, "has_n...
from functools import wraps from werkzeug.exceptions import BadRequest from flask import request, jsonify def body_required(f): @wraps(f) def decorated_function(*args, **kwargs): try: # Set Force True to allow integration easily with any frontend. data = request.get_json(force=...
{ "repo_name": "yograterol/viperid", "path": "backend/viperid/utils.py", "copies": "1", "size": "1246", "license": "mit", "hash": 8851705519647142000, "line_mean": 27.3181818182, "line_max": 80, "alpha_frac": 0.5288924559, "autogenerated": false, "ratio": 4.223728813559322, "config_test": false,...
from functools import wraps from werkzeug.exceptions import Forbidden def import_user(): try: from flask.ext.login import current_user return current_user except ImportError: raise ImportError( 'User argument not passed and Flask-Login current_user could not be imported.') ...
{ "repo_name": "compiteing/flask-ponypermission", "path": "decorators.py", "copies": "1", "size": "1604", "license": "mit", "hash": 8791429048777255000, "line_mean": 32.4166666667, "line_max": 121, "alpha_frac": 0.5947630923, "autogenerated": false, "ratio": 4.556818181818182, "config_test": fal...
from functools import wraps from werkzeug import routing from werkzeug.routing import BaseConverter from . import utils def rule_dispatcher(rule, request, response): if getattr(rule, '_steinie_dispatchable', False): request.original_path = request.path request.path = request.original_path.replace...
{ "repo_name": "tswicegood/steinie", "path": "steinie/routing.py", "copies": "1", "size": "4506", "license": "apache-2.0", "hash": 2342661665469464600, "line_mean": 27.7006369427, "line_max": 75, "alpha_frac": 0.5690190857, "autogenerated": false, "ratio": 4.133944954128441, "config_test": false...
from functools import wraps from werkzeug import secure_filename, escape from flask import g, session, redirect, url_for from forms import LoginForm, SearchForm, DeleteForm, ExportForm, ImportForm def login_required(f): "view decorator that redirects nonauthenticated users to index" @wraps(f) def decorated...
{ "repo_name": "korylprince/lanschool_class_gen", "path": "util.py", "copies": "1", "size": "1156", "license": "bsd-3-clause", "hash": -8575836022403600000, "line_mean": 36.2903225806, "line_max": 80, "alpha_frac": 0.6920415225, "autogenerated": false, "ratio": 4.013888888888889, "config_test": ...
from functools import wraps from wraptor import context class throttle(object): """ Throttle a function to execute at most 1 time per <seconds> seconds The function is executed on the forward edge. """ def __init__(self, seconds=1, instance_method=False, return_throttle_result=False): self....
{ "repo_name": "carlsverre/wraptor", "path": "wraptor/decorators/throttle.py", "copies": "1", "size": "1460", "license": "mit", "hash": -8047561446131984000, "line_mean": 41.9411764706, "line_max": 87, "alpha_frac": 0.597260274, "autogenerated": false, "ratio": 4.591194968553459, "config_test": ...
from functools import wraps from xml.etree.ElementTree import XML import json import requests __version__ = "0.6" ALL = '*' ENDPOINT_URL = 'http://api.census.gov/data/%s/%s' DEFINITIONS = { 'acs5': { '2011': 'http://www.census.gov/developers/data/acs_5yr_2011_var.xml', '2010': 'http://www.census.g...
{ "repo_name": "UDST/census", "path": "census/core.py", "copies": "1", "size": "10773", "license": "bsd-3-clause", "hash": 1579940915145653000, "line_mean": 29.6051136364, "line_max": 95, "alpha_frac": 0.5552770816, "autogenerated": false, "ratio": 3.3487721479639414, "config_test": false, "ha...
from functools import wraps from xml.etree.ElementTree import XML import json import requests __version__ = "0.7" ALL = '*' ENDPOINT_URL = 'http://api.census.gov/data/%s/%s' DEFINITIONS = { 'acs5': { '2013': 'http://api.census.gov/data/2013/acs5/variables.xml', '2012': 'http://api.census.gov/data...
{ "repo_name": "joehand/census", "path": "census/core.py", "copies": "1", "size": "12002", "license": "bsd-3-clause", "hash": 496316733574490000, "line_mean": 30.6675461741, "line_max": 95, "alpha_frac": 0.5582402933, "autogenerated": false, "ratio": 3.3283416528008876, "config_test": false, "...
from functools import wraps from xml.etree.ElementTree import XML import json __version__ = "0.7" ALL = '*' ENDPOINT_URL = 'http://api.census.gov/data/%s/%s' DEFINITIONS = { 'acs5': { '2013': 'http://api.census.gov/data/2013/acs5/variables.xml', '2012': 'http://api.census.gov/data/2012/acs5/variab...
{ "repo_name": "dmc2015/census", "path": "census/core.py", "copies": "1", "size": "11946", "license": "bsd-3-clause", "hash": 1297283924011553000, "line_mean": 30.7712765957, "line_max": 95, "alpha_frac": 0.5581784698, "autogenerated": false, "ratio": 3.3275766016713093, "config_test": false, ...
from functools import wraps import aiohttp import logging logger = logging.getLogger(__name__) async def get_ticket(account, password): """You'll receive a ticket and a ton of other things that you probably won't need unless you're making an f-chat client. Tickets are valid for 24 hours from issue, and inval...
{ "repo_name": "StormyDragon/python-flist", "path": "flist/api.py", "copies": "1", "size": "5114", "license": "bsd-2-clause", "hash": 6765148392708345000, "line_mean": 27.8926553672, "line_max": 118, "alpha_frac": 0.6691435276, "autogenerated": false, "ratio": 3.90381679389313, "config_test": fa...
from functools import wraps import asyncio from concurrent.futures import TimeoutError from .log import logger def _default_retry_for_result(result): return False def _default_retry_for_exception(exception): return False def retry(*dargs, **dkwargs): if len(dargs) == 1 and callable(dargs[0]): ...
{ "repo_name": "nerandell/async_retrial", "path": "retrial/retrial/retry.py", "copies": "1", "size": "4143", "license": "bsd-2-clause", "hash": 6631904108205326000, "line_mean": 40.8484848485, "line_max": 120, "alpha_frac": 0.5942553705, "autogenerated": false, "ratio": 4.3427672955974845, "conf...
from functools import wraps import asyncio import random from .connection import Connection from .exceptions import NoAvailableConnectionsInPoolError from .protocol import RedisProtocol, Script from .nodemanager import NodeManager from .crc import crc16 __all__ = ('Pool',) class Pool: """ Pool of connectio...
{ "repo_name": "rightbraindev/asyncio-redis-cluster", "path": "asyncio_redis_cluster/pool.py", "copies": "1", "size": "6873", "license": "bsd-2-clause", "hash": -3439923496479854000, "line_mean": 33.5376884422, "line_max": 113, "alpha_frac": 0.5866433872, "autogenerated": false, "ratio": 4.4980366...