text
stringlengths
0
1.05M
meta
dict
from functools import wraps from flask import \ render_template, redirect, url_for, \ abort, flash, request, current_app, \ make_response from flask_login import \ login_required, current_user, \ login_user, logout_user from sqlalchemy.orm import lazyload from datetime import date, datetime, timed...
{ "repo_name": "alexd2580/evelyn", "path": "evelyn/views.py", "copies": "1", "size": "16334", "license": "mit", "hash": -592651581599556900, "line_mean": 33.7531914894, "line_max": 99, "alpha_frac": 0.5884045549, "autogenerated": false, "ratio": 3.946363856003866, "config_test": false, "has_no...
from functools import wraps from flask import redirect, session, url_for, flash, render_template # Decorator to require log in def login_required(f): @wraps(f) def wrap(*args, **kwargs): if "logged_in" in session: return f(*args, **kwargs) else: flash("not logged in") ...
{ "repo_name": "naliuj/WHHB-Twitter-Bot", "path": "user_management/page_restrictions.py", "copies": "1", "size": "1067", "license": "mit", "hash": -1753373738998964700, "line_mean": 27.8378378378, "line_max": 86, "alpha_frac": 0.5932521087, "autogenerated": false, "ratio": 3.937269372693727, "co...
from functools import wraps from flask import redirect, url_for from flask.ext.login import current_user from models import * import re from unicodedata import normalize import bbcode def get_current_user_role(): user = User.query.filter_by(email=current_user.email).first() roles = [] for role in user.rol...
{ "repo_name": "VincentTide/vincenttide", "path": "app/utility.py", "copies": "1", "size": "2755", "license": "mit", "hash": -5929056492946702000, "line_mean": 30.6666666667, "line_max": 70, "alpha_frac": 0.5720508167, "autogenerated": false, "ratio": 3.8052486187845305, "config_test": false, ...
from functools import wraps from flask import redirect, url_for from urlobject import URLObject from requests_oauthlib import OAuth1Session as BaseOAuth1Session from requests_oauthlib import OAuth2Session as BaseOAuth2Session from oauthlib.common import to_unicode from werkzeug.utils import cached_property from flask_d...
{ "repo_name": "singingwolfboy/flask-dance", "path": "flask_dance/consumer/requests.py", "copies": "1", "size": "7241", "license": "mit", "hash": -452918958073882000, "line_mean": 35.205, "line_max": 88, "alpha_frac": 0.6276757354, "autogenerated": false, "ratio": 4.372584541062802, "config_test...
from functools import wraps from flask import render_template, flash, redirect, url_for, request, g from flask.ext.login import login_user, logout_user, current_user, login_required from app import app, db, lm, rc from forms import LoginForm, SignupForm, CreateGameForm, JoinGameForm from wtforms.ext.sqlalchemy.orm impo...
{ "repo_name": "vigov5/pvp-game", "path": "app/views.py", "copies": "1", "size": "6654", "license": "mit", "hash": 497848452074567740, "line_mean": 32.7766497462, "line_max": 100, "alpha_frac": 0.6190261497, "autogenerated": false, "ratio": 3.4602184087363494, "config_test": false, "has_no_key...
from functools import wraps from flask import request, abort from flask.views import MethodView class NamedMethod(object): def __init__(self, name, http_method_name): self.name = name self.http_method_name = http_method_name def __call__(self, method): self.method = method if s...
{ "repo_name": "denz/swarm-crawler", "path": "swarm_crawler/serve/namedview.py", "copies": "1", "size": "4412", "license": "bsd-3-clause", "hash": 7112835163810690000, "line_mean": 35.775, "line_max": 90, "alpha_frac": 0.569356301, "autogenerated": false, "ratio": 4.1195144724556485, "config_tes...
from functools import wraps from flask import request, abort import jwt class SimpleJWT: """ Class to manage JWT Token in Flask """ def __init__(self, secret, realm=None, algorithms=None): """ Class constructor Initializes the secret key for the token :param secret: s...
{ "repo_name": "depa77/flask-simplejwt", "path": "flask_simplejwt/flask_simplejwt.py", "copies": "1", "size": "2189", "license": "mit", "hash": -281970958104429950, "line_mean": 29.4166666667, "line_max": 80, "alpha_frac": 0.5523069895, "autogenerated": false, "ratio": 4.952488687782806, "config...
from functools import wraps from flask import request, Blueprint, jsonify from api.errors import * from api.models import Snippet api_v1 = Blueprint('v1', __name__) ######################## Authentication ################################ def requires_authentication(func): @wraps(func) def wrapper(*args, **...
{ "repo_name": "kirang89/youten", "path": "api/v1/views.py", "copies": "1", "size": "2823", "license": "mit", "hash": -6957500527335435000, "line_mean": 27.23, "line_max": 86, "alpha_frac": 0.5671271697, "autogenerated": false, "ratio": 4.03862660944206, "config_test": false, "has_no_keywords"...
from functools import wraps from flask import request, Blueprint, render_template, jsonify, flash, \ redirect, url_for from my_app import db, app from my_app.catalog.models import Product, Category from sqlalchemy.orm.util import join catalog = Blueprint('catalog', __name__) def template_or_json(template=None): ...
{ "repo_name": "nikitabrazhnik/flask2", "path": "Module 2/Chapter04/my_app/catalog/views.py", "copies": "1", "size": "3469", "license": "mit", "hash": 2270357848639896300, "line_mean": 29.6991150442, "line_max": 77, "alpha_frac": 0.6520611127, "autogenerated": false, "ratio": 3.791256830601093, ...
from functools import wraps from flask import request, current_app, make_response, Response def json_or_jsonp(func): """Wrap response in JSON or JSONP style""" @wraps(func) def _(*args, **kwargs): mimetype = 'application/javascript' callback = request.args.get('callback', None) if ...
{ "repo_name": "kxxoling/flask-decorators", "path": "flask_decorators/__init__.py", "copies": "1", "size": "1775", "license": "mit", "hash": 2261038194957412000, "line_mean": 26.734375, "line_max": 77, "alpha_frac": 0.5616901408, "autogenerated": false, "ratio": 4.186320754716981, "config_test":...
from functools import wraps from flask import request, current_app import random, math import re import jinja2 from time import sleep import datetime import stripe import emailer from unicode_helpers import to_unicode_or_bust import unicodedata from sqlalchemy.exc import IntegrityError, DataError, InvalidRequestError ...
{ "repo_name": "total-impact/total-impact-webapp", "path": "util.py", "copies": "2", "size": "10827", "license": "mit", "hash": 3890508158740738000, "line_mean": 26.7615384615, "line_max": 113, "alpha_frac": 0.6075551861, "autogenerated": false, "ratio": 3.6565349544072947, "config_test": false,...
from functools import wraps from flask import request, g, jsonify from itsdangerous import TimedJSONWebSignatureSerializer as Serializer from itsdangerous import SignatureExpired, BadSignature from index import app TWO_WEEKS = 1209600 def generate_token(user, expiration=TWO_WEEKS): s = Serializer(app.config['SEC...
{ "repo_name": "pyalwin/redux", "path": "application/utils/auth.py", "copies": "9", "size": "1130", "license": "mit", "hash": -1529423264327388000, "line_mean": 26.5609756098, "line_max": 89, "alpha_frac": 0.6477876106, "autogenerated": false, "ratio": 4.0647482014388485, "config_test": false, ...
from functools import wraps from flask import request, g, jsonify from itsdangerous import TimedJSONWebSignatureSerializer as Serializer from itsdangerous import SignatureExpired, BadSignature from .. import app TWO_WEEKS = 1209600 FIVE_SECOND = 5 def generate_token(user, expiration=TWO_WEEKS): s = Serializer(a...
{ "repo_name": "mortbauer/webapp", "path": "application/utils/auth.py", "copies": "1", "size": "1144", "license": "mit", "hash": 8752232215745918000, "line_mean": 25.6046511628, "line_max": 89, "alpha_frac": 0.6451048951, "autogenerated": false, "ratio": 4, "config_test": false, "has_no_keywor...
from functools import wraps from flask import request, g, jsonify from itsdangerous import (TimedJSONWebSignatureSerializer as Serializer, SignatureExpired, BadSignature) from index import app TWO_WEEKS = 1209600 def generate_token(user, expiration=TWO_WEEKS): s = Serializer(app.conf...
{ "repo_name": "groschatchauve/xCluster", "path": "server/flask/application/utils/auth.py", "copies": "1", "size": "1192", "license": "unlicense", "hash": 3063309234137416000, "line_mean": 28.825, "line_max": 139, "alpha_frac": 0.6367449664, "autogenerated": false, "ratio": 4.124567474048443, "c...
from functools import wraps from flask import request, jsonify, _app_ctx_stack import jwt import os from ..models import Person from ..utils import get_one_or_create from .. import db, graph jwt_secret = os.environ.get('JWT_SECRET', 'superSECRETth!ng') client_id = os.environ.get('AUTH0_ID', 'None') # Strip start and ...
{ "repo_name": "squarenomad/historia", "path": "backend/app/api/decorators.py", "copies": "1", "size": "3393", "license": "mit", "hash": 1793465889123929900, "line_mean": 34.34375, "line_max": 78, "alpha_frac": 0.4939581491, "autogenerated": false, "ratio": 4.805949008498583, "config_test": fals...
from functools import wraps from flask import request, jsonify, current_app def authenticate(authorization): from model import User import jwt current_app.logger.info(authorization) try: auth_method, token = authorization.split(':') decoded = jwt.decode(token, '', algorithm='HS256', ...
{ "repo_name": "thomasbhatia/kigata", "path": "app/contrib/mod_auth/__init__.py", "copies": "1", "size": "1323", "license": "bsd-3-clause", "hash": -8284672911269149000, "line_mean": 26, "line_max": 79, "alpha_frac": 0.5993953137, "autogenerated": false, "ratio": 4.267741935483871, "config_test"...
from functools import wraps from flask import request,jsonify import hmac, hashlib from nishu import get_application_model def auth_decorator(func): @wraps(func) def decorator_func(*args,**kwargs): user = request.headers.get('user') api_key = request.headers.get('api_key') ...
{ "repo_name": "iamrajhans/FlaskBackend", "path": "drone/utility/auth_required.py", "copies": "1", "size": "2334", "license": "mit", "hash": -8892603922238337000, "line_mean": 33.8358208955, "line_max": 101, "alpha_frac": 0.5998286204, "autogenerated": false, "ratio": 4.0310880829015545, "config...
from functools import wraps from flask import request from flask.ext.restful import reqparse, abort, Resource from flask.views import http_method_funcs, View, MethodView import six from werkzeug.utils import cached_property from flask.ext.presst.utils.routes import route_from from flask_presst.parsing import PresstArgu...
{ "repo_name": "svenstaro/flask-presst", "path": "flask_presst/nesting.py", "copies": "2", "size": "6441", "license": "mit", "hash": -3210464899304306000, "line_mean": 41.6622516556, "line_max": 118, "alpha_frac": 0.6582828753, "autogenerated": false, "ratio": 4.105162523900574, "config_test": f...
from functools import wraps from flask import request from flask import make_response import hashlib TOKEN = hashlib.sha256("SAMPLE UNIQI TOKEN FOR USER").hexdigest() TOKEN_HEADER_NAME = "MY_AUTH_TOKEN" def validate_user(service, username, password): return username == "john" and password == "doe123" def aut...
{ "repo_name": "BartGo/flask-drafts", "path": "app/examples/lynda-webapiflask/decorators.py", "copies": "1", "size": "1286", "license": "mit", "hash": -6867504592195988000, "line_mean": 31.15, "line_max": 98, "alpha_frac": 0.6283048212, "autogenerated": false, "ratio": 4.121794871794871, "config...
from functools import wraps from flask import request from itsdangerous import URLSafeSerializer from config import * import json def response_msg(status, msg, **kwargs): res = {} res['status'] = status res['msg'] = msg for name, value in kwargs.items(): res[name] = value return json.dumps(...
{ "repo_name": "nirmitgoyal/longclaw", "path": "longclaw/auth.py", "copies": "1", "size": "1881", "license": "mit", "hash": -1337179003385104100, "line_mean": 29.3548387097, "line_max": 78, "alpha_frac": 0.5369484317, "autogenerated": false, "ratio": 4.226966292134832, "config_test": false, "h...
from functools import wraps from flask import request, redirect, flash from flask.ext.login import current_user # - Note: This code doesn't seem to work. # from .forms import LoginForm # def use_commmon_route_variables(f): # @wraps(f) # def wrap(*args, **kwargs): # logged_in = current_user.is_authentic...
{ "repo_name": "joeflack4/vanillerp", "path": "app/route_decorators.py", "copies": "1", "size": "6417", "license": "mit", "hash": 4144072815998189000, "line_mean": 36.9704142012, "line_max": 119, "alpha_frac": 0.6228767337, "autogenerated": false, "ratio": 3.9440688383527966, "config_test": fals...
from functools import wraps from flask import request, redirect, url_for, render_template, flash, abort, \ jsonify, session, g from flaskr import app, db from flaskr.models import Entry, User def login_required(f): @wraps(f) def decorated_view(*args, **kwargs): if g.user is None: re...
{ "repo_name": "nwiizo/workspace_2017", "path": "etc/flask/app/flaskr/views.py", "copies": "2", "size": "3368", "license": "mit", "hash": -7436439972519352000, "line_mean": 29.3423423423, "line_max": 78, "alpha_frac": 0.6160926366, "autogenerated": false, "ratio": 3.5906183368869935, "config_tes...
from functools import wraps from flask import request, render_template, flash, redirect, url_for, \ session, Blueprint, g, abort from flask.ext.login import current_user, login_user, logout_user, \ login_required from wtforms import PasswordField from my_app import db, login_manager from flask.ext.admin import ...
{ "repo_name": "nikitabrazhnik/flask2", "path": "Module 2/Chapter08/my_app/auth/views.py", "copies": "2", "size": "8273", "license": "mit", "hash": -5571358780802301000, "line_mean": 29.304029304, "line_max": 78, "alpha_frac": 0.6338692131, "autogenerated": false, "ratio": 3.8247803975959314, "c...
from functools import wraps from flask import request, Response,Blueprint,render_template,jsonify,current_app,abort,redirect,url_for from bluespot.extensions import db from bluespot.base.utils.helper import format_url from bluespot.base.utils.forms import print_errors,get_errors from bluespot.guest.models import Guest...
{ "repo_name": "unifispot/unifispot-free", "path": "bluespot/admin/views.py", "copies": "1", "size": "1406", "license": "mit", "hash": 8349845419367925000, "line_mean": 30.2444444444, "line_max": 138, "alpha_frac": 0.6984352774, "autogenerated": false, "ratio": 3.9717514124293785, "config_test":...
from functools import wraps from flask import request, Response, current_app from userver.object.application import Application from binascii import unhexlify, hexlify from binascii import Error as hex_error from base64 import b64decode from userver.object.device import Device from userver.object.gateway import Gateway...
{ "repo_name": "soybean217/lora-python", "path": "UServer/http_api_oauth/api/decorators.py", "copies": "1", "size": "14290", "license": "mit", "hash": 5703446886368417000, "line_mean": 36.4109947644, "line_max": 98, "alpha_frac": 0.5818754374, "autogenerated": false, "ratio": 3.5327564894932015, ...
from functools import wraps from flask import request, Response, g, current_app from ..models import * from expiringdict import ExpiringDict from datetime import timedelta class APIAuthWrapper(): def __init__(self): max_age = timedelta(minutes=10) self.cache = ExpiringDict(max_len=100, max_age_seco...
{ "repo_name": "WildflowerSchools/sensei", "path": "app/api/api_auth_wrapper.py", "copies": "1", "size": "2201", "license": "mit", "hash": -6649146553288922000, "line_mean": 33.9365079365, "line_max": 79, "alpha_frac": 0.597455702, "autogenerated": false, "ratio": 4.358415841584159, "config_test...
from functools import wraps from flask import request, Response from bson.json_util import dumps from utils.config import get_app_configurations def check_auth(username, password): """This function is called to check if a username / password combination is valid. """ config = get_app_configurations() ...
{ "repo_name": "dgutman/ADRCPathViewer", "path": "api/utils/auth.py", "copies": "1", "size": "1026", "license": "mit", "hash": -7708974186969005000, "line_mean": 31.09375, "line_max": 88, "alpha_frac": 0.6608187135, "autogenerated": false, "ratio": 4.239669421487603, "config_test": false, "has...
from functools import wraps from flask import request, Response from flask_philo import app import base64 """ http://flask.pocoo.org/snippets/8/ This module exposes a decorator that can be used in a flask_philo app to enforce basic auth on an endpoint. An example of usage can be found in `test/tests/test_app/views/au...
{ "repo_name": "maigfrga/flaskutils", "path": "flask_philo/auth.py", "copies": "2", "size": "1469", "license": "apache-2.0", "hash": 8239104497078781000, "line_mean": 29.6041666667, "line_max": 77, "alpha_frac": 0.6364874064, "autogenerated": false, "ratio": 4.1971428571428575, "config_test": fa...
from functools import wraps from flask import request, Response from userver.object.application import Application from binascii import unhexlify, hexlify from binascii import Error as hex_error from userver.object.device import Device from userver.object.gateway import Gateway from userver.object.group import Group f...
{ "repo_name": "soybean217/lora-python", "path": "UServer/admin_server/admin_http_api/api/decorators.py", "copies": "1", "size": "10649", "license": "mit", "hash": -5688880851124374000, "line_mean": 32.8063492063, "line_max": 93, "alpha_frac": 0.5768616772, "autogenerated": false, "ratio": 3.55085...
from functools import wraps from flask import request, Response import json from pizza_auth.ldaptools import LDAPTools with open('config.json', 'r') as fh: config = json.loads(fh.read()) ldaptools = LDAPTools(config) def check_auth(username, password): """This function is called to check if a username / password ...
{ "repo_name": "andimiller/timerboard", "path": "authtools.py", "copies": "1", "size": "1095", "license": "mit", "hash": -9212926809857480000, "line_mean": 25.7073170732, "line_max": 63, "alpha_frac": 0.7369863014, "autogenerated": false, "ratio": 3.4761904761904763, "config_test": false, "has...
from functools import wraps from flask import request, Response import json from config import HR_CHATBOT_AUTHKEY json_encode = json.JSONEncoder().encode def check_auth(auth): return auth == HR_CHATBOT_AUTHKEY def authenticate(): return Response(json_encode({'ret': 401, 'response': {'text': 'Could not ver...
{ "repo_name": "hansonrobotics/chatbot", "path": "src/chatbot/server/auth.py", "copies": "1", "size": "1655", "license": "mit", "hash": -8029137637932749000, "line_mean": 29.0909090909, "line_max": 100, "alpha_frac": 0.5564954683, "autogenerated": false, "ratio": 4.534246575342466, "config_test"...
from functools import wraps from flask import request, Response import log log = logging.getLogger('simple_example') password = None gm_password = None def check_auth(try_password): """This function is called to check if a password is valid. """ return try_password == password or try_password == gm_passw...
{ "repo_name": "jghibiki/Cursed", "path": "terminal/authentication.py", "copies": "1", "size": "1247", "license": "mit", "hash": -5726900198293240000, "line_mean": 28, "line_max": 66, "alpha_frac": 0.6623897354, "autogenerated": false, "ratio": 4.129139072847682, "config_test": false, "has_no_...
from functools import wraps from flask import request,url_for,session,Response,g import api import urllib.parse import flask import os SRC_DIR=os.path.dirname(os.path.realpath(__file__)) def redirect(path,next_path=None): print(next_path) if(next_path): if(next_path[-1]=="?"): next_path = ne...
{ "repo_name": "kyoppie/kyoppie-web", "path": "src/utils.py", "copies": "1", "size": "1659", "license": "mit", "hash": -1634354299510523600, "line_mean": 32.18, "line_max": 68, "alpha_frac": 0.5563592526, "autogenerated": false, "ratio": 3.5524625267665955, "config_test": false, "has_no_keywor...
from functools import wraps from flask import session, Blueprint, url_for, request, redirect, flash from flask.ext.login import login_required from .angular_view import register_or_login_user from ..extensions import oauth users = Blueprint("users", __name__) facebook = oauth.remote_app( 'facebook', base_url...
{ "repo_name": "Bayesian-Skulls/carpool_app", "path": "carpool_app/views/users.py", "copies": "1", "size": "2653", "license": "mit", "hash": -6927446006144994000, "line_mean": 32.1625, "line_max": 79, "alpha_frac": 0.6226912929, "autogenerated": false, "ratio": 3.8008595988538683, "config_test":...
from functools import wraps from flask import session, flash, redirect, url_for, abort from apps.models import User def current_user(): user = None if 'user_id' in session: user_id = session['user_id'] user = User.get(User.id == user_id) return user def admin_required(func): @wraps(...
{ "repo_name": "ap13p/elearn", "path": "apps/decorators.py", "copies": "1", "size": "1601", "license": "bsd-3-clause", "hash": -4234044272179362300, "line_mean": 29.7884615385, "line_max": 79, "alpha_frac": 0.572142411, "autogenerated": false, "ratio": 3.876513317191283, "config_test": false, ...
from functools import wraps from flask import session, redirect, url_for, request, abort from alexandria import mongo def not_even_one(f): @wraps(f) def decorated_function(*args, **kwargs): if mongo.Books.find_one() is None: return redirect(url_for('upload')) return f(*args, **kwarg...
{ "repo_name": "citruspi/Alexandria", "path": "alexandria/decorators.py", "copies": "1", "size": "1306", "license": "mit", "hash": -4601929875483794000, "line_mean": 22.3214285714, "line_max": 74, "alpha_frac": 0.5727411945, "autogenerated": false, "ratio": 4.043343653250774, "config_test": fals...
from functools import wraps from flask import session, request, redirect, url_for from flask_oauthlib.client import OAuth, OAuthException from . import app auth = OAuth().remote_app( 'recurse', base_url = 'https://www.recurse.com/api/v1/', access_token_url = 'https://www.recurse.com/oauth/to...
{ "repo_name": "mikkqu/rc-chrysalis", "path": "scapp/oauth.py", "copies": "1", "size": "1530", "license": "bsd-2-clause", "hash": 8932920542284013000, "line_mean": 33.7954545455, "line_max": 81, "alpha_frac": 0.6692810458, "autogenerated": false, "ratio": 3.9130434782608696, "config_test": false...
from functools import wraps from flask import url_for as flask_url_for, redirect, render_template, request, g, abort from flask_login import login_required from piipod import config import flask_login def current_user(): """Returns currently-logged-in user""" return flask_login.current_user def render(f, *a...
{ "repo_name": "alvinwan/piipod", "path": "piipod/views.py", "copies": "2", "size": "2072", "license": "apache-2.0", "hash": -7066383654344809000, "line_mean": 29.4705882353, "line_max": 88, "alpha_frac": 0.625, "autogenerated": false, "ratio": 3.9242424242424243, "config_test": false, "has_no...
from functools import wraps from flask_login import current_user from flask import flash, redirect, request, abort from comport.department.models import Extractor, Department def authorized_access_only(dataset=None): ''' Decorates views that require authentication if the department is not public ''' def ch...
{ "repo_name": "codeforamerica/comport", "path": "comport/decorators.py", "copies": "1", "size": "3787", "license": "bsd-3-clause", "hash": -3619953759276854000, "line_mean": 40.6153846154, "line_max": 137, "alpha_frac": 0.6311064167, "autogenerated": false, "ratio": 4.640931372549019, "config_t...
from functools import wraps from google.appengine.api import users from app.user.forms import SettingsForm from app.user.models import UserModel, create_user, update_user from flask import Blueprint, redirect, request, g, url_for, render_template USER_MODULE = Blueprint('user', __name__, url_prefix='/user') def logi...
{ "repo_name": "sourlows/rating-cruncher", "path": "src/app/user/views.py", "copies": "1", "size": "1547", "license": "apache-2.0", "hash": 3427060543305969000, "line_mean": 29.94, "line_max": 75, "alpha_frac": 0.67291532, "autogenerated": false, "ratio": 3.5481651376146788, "config_test": false...
from functools import wraps from google.appengine.ext import db def user_logged_in(function): """checks whether user is logged in""" @wraps(function) def wrapper(self, *args, **kwargs): if not self.user: self.error(403) return self.redirect("/") else: kw...
{ "repo_name": "brusznicki/multi-user-blog", "path": "helpers/decorators.py", "copies": "1", "size": "2597", "license": "mit", "hash": 5481319014965212000, "line_mean": 27.2282608696, "line_max": 71, "alpha_frac": 0.5225259915, "autogenerated": false, "ratio": 4.1552, "config_test": false, "ha...
from functools import wraps from hashlib import sha1 import hmac import json from django.db import models from django.db.models.query import QuerySet from django.conf import settings from django.core.cache import cache import logging logger = logging.getLogger(__name__) DEFAULT = 60 * 60 * 6 # 6 hours EXTENDED = 60 ...
{ "repo_name": "kronosapiens/precisicache", "path": "precisicache.py", "copies": "1", "size": "5063", "license": "mit", "hash": -3296140219135629000, "line_mean": 32.3092105263, "line_max": 99, "alpha_frac": 0.5956942524, "autogenerated": false, "ratio": 3.864885496183206, "config_test": false, ...
from functools import wraps from htmlmin import Minifier from flask import request, current_app import warnings class HTMLMIN(object): def __init__(self, app=None, **kwargs): self.app = app if app is not None: self.init_app(app) default_options = { 'remove_comments...
{ "repo_name": "hamidfzm/Flask-HTMLmin", "path": "flask_htmlmin/__init__.py", "copies": "1", "size": "2085", "license": "bsd-3-clause", "hash": -8687123101209118000, "line_mean": 27.9583333333, "line_max": 73, "alpha_frac": 0.5342925659, "autogenerated": false, "ratio": 4.1783567134268536, "conf...
from functools import wraps from http import HTTPStatus from flask import abort, request from flask_login import current_user from flask_principal import Permission, RoleNeed, UserNeed from flask_security.decorators import auth_required as flask_security_auth_required from backend.utils import was_decorated_without_pa...
{ "repo_name": "briancappello/flask-react-spa", "path": "backend/security/decorators.py", "copies": "1", "size": "5953", "license": "mit", "hash": 2233047957083996700, "line_mean": 33.2126436782, "line_max": 103, "alpha_frac": 0.6260708886, "autogenerated": false, "ratio": 4.0386702849389415, "c...
from functools import wraps from http import HTTPStatus from flask import current_app, request from flask_restx import abort from app.database import AuthTokens from app.api.constants import AUTH_HEADER_KEY class TokenRequiredMixin: auth_methods = ['get', 'post', 'put', 'patch', 'delete'] auth_message = 'Aut...
{ "repo_name": "mrf345/FQM", "path": "app/api/mixins.py", "copies": "1", "size": "2866", "license": "mpl-2.0", "hash": -7011488283458720000, "line_mean": 31.5681818182, "line_max": 88, "alpha_frac": 0.5725750174, "autogenerated": false, "ratio": 4.177842565597667, "config_test": false, "has_no...
from functools import wraps from httplib import FORBIDDEN, NOT_FOUND, INTERNAL_SERVER_ERROR, BAD_REQUEST from django.http import JsonResponse from django.views import defaults as default_views from .constants import CSRF_INVALID def csrf_failure(request, reason=''): data = { 'error': True, 'err_ms...
{ "repo_name": "zh012/djrest", "path": "djrest/handlers.py", "copies": "1", "size": "1386", "license": "mit", "hash": -1679811391227548400, "line_mean": 37.5, "line_max": 112, "alpha_frac": 0.6847041847, "autogenerated": false, "ratio": 3.6861702127659575, "config_test": false, "has_no_keyword...
from functools import wraps from . import exceptions, http, application from future.utils import with_metaclass import re def action(url, protection=None, authentication=False, method=None): # url e.g: /<id>/action_name def dec(func): if protection: func._protection_shield_method = protec...
{ "repo_name": "felipevolpone/onhands", "path": "ray-core/ray/actions.py", "copies": "2", "size": "3568", "license": "mit", "hash": -4439513001319933000, "line_mean": 31.1441441441, "line_max": 118, "alpha_frac": 0.5880044843, "autogenerated": false, "ratio": 4.059158134243458, "config_test": fa...
from functools import wraps from .. import Filter from webob.exc import HTTPUnauthorized, HTTPForbidden class AuthenticationProvider: def __init__(self, ctx, request): self.request = request self.ctx = ctx @property def principal(self): raise HTTPUnauthorized() def has_permis...
{ "repo_name": "comynli/m", "path": "m/security/__init__.py", "copies": "1", "size": "1659", "license": "apache-2.0", "hash": -3214238680480046000, "line_mean": 27.6034482759, "line_max": 79, "alpha_frac": 0.6154309825, "autogenerated": false, "ratio": 4.634078212290503, "config_test": false, ...
from functools import wraps from importlib import import_module from puck.utils import fancy_import from puck import stdlib THINGS_TO_MONKEYPATCH = { 'puck.core.enebriate': '__builtin__.enumerate', } def patch_thing(source, target): target_module_path, target_name = target.rsplit('.', 1) target_module ...
{ "repo_name": "pipermerriam/puck", "path": "puck/chaos.py", "copies": "1", "size": "1599", "license": "bsd-3-clause", "hash": 984936212112260100, "line_mean": 25.65, "line_max": 64, "alpha_frac": 0.6535334584, "autogenerated": false, "ratio": 3.780141843971631, "config_test": false, "has_no_k...
from functools import wraps from importlib import import_module 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.module_loading import impor...
{ "repo_name": "ar4s/django", "path": "django/db/utils.py", "copies": "3", "size": "8960", "license": "bsd-3-clause", "hash": 4264144731435288600, "line_mean": 31, "line_max": 92, "alpha_frac": 0.5690848214, "autogenerated": false, "ratio": 4.587813620071684, "config_test": false, "has_no_keyw...
from functools import wraps from importlib import reload import boto3 from moto import mock_s3 from aws_etl_tools import config from aws_etl_tools.guard import requires_s3_base_path class MockS3Connection: '''This is a decorator for mocking a connection to S3 for the life of a test. You can use it in tw...
{ "repo_name": "shopkeep/aws_etl_tools", "path": "aws_etl_tools/mock_s3_connection.py", "copies": "1", "size": "1368", "license": "apache-2.0", "hash": 8627614991463557000, "line_mean": 35, "line_max": 102, "alpha_frac": 0.6703216374, "autogenerated": false, "ratio": 3.619047619047619, "config_t...
from functools import wraps from inspect import getargspec import argparse import logging import sys from parse_this.core import (_check_types, _get_args_and_defaults, _get_arg_parser, _get_args_to_parse, _call, ParseThisError, Self, Class, FullHelpAction, ...
{ "repo_name": "bertrandvidal/parse_this", "path": "parse_this/__init__.py", "copies": "1", "size": "10214", "license": "mit", "hash": -8645865581441239000, "line_mean": 44.3955555556, "line_max": 80, "alpha_frac": 0.5609947131, "autogenerated": false, "ratio": 4.772897196261682, "config_test": ...
from functools import wraps from inspect import getcallargs from logging import getLogger logger = getLogger(__name__) class ValidationError(Exception): def __init__(self, message): self.message = message class BaseArgValidator(object): """ArgValidatorの基底クラス。引数のバリデーションを行う。 使い方 1. 派生クラスでバリ...
{ "repo_name": "beproud/beproudbot", "path": "src/haro/arg_validator.py", "copies": "1", "size": "3972", "license": "mit", "hash": 1862300806025457700, "line_mean": 23.976744186, "line_max": 75, "alpha_frac": 0.5518311608, "autogenerated": false, "ratio": 2.5470355731225296, "config_test": false...
from functools import wraps from inspect import getmembers, isfunction from webob import exc import six from .decorators import expose from .util import _cfg, iscontroller __all__ = ['unlocked', 'secure', 'SecureController'] if six.PY3: from .compat import is_bound_method as ismethod else: from inspect impo...
{ "repo_name": "pecan/pecan", "path": "pecan/secure.py", "copies": "2", "size": "7242", "license": "bsd-3-clause", "hash": 8602843068564160000, "line_mean": 30.2155172414, "line_max": 77, "alpha_frac": 0.6121237227, "autogenerated": false, "ratio": 4.3081499107674, "config_test": false, "has_n...
from functools import wraps from inspect import getmembers, isfunction from webob import exc import six if six.PY3: from .compat import is_bound_method as ismethod else: from inspect import ismethod from .decorators import expose from .util import _cfg, iscontroller __all__ = ['unlocked', 'secure', 'SecureC...
{ "repo_name": "citrix-openstack-build/pecan", "path": "pecan/secure.py", "copies": "1", "size": "7033", "license": "bsd-3-clause", "hash": -2972380329412463000, "line_mean": 29.711790393, "line_max": 77, "alpha_frac": 0.6125408787, "autogenerated": false, "ratio": 4.32002457002457, "config_test...
from functools import wraps from inspect import signature, _empty, isclass, getmro from .core import validate def validate_fn(validator=None, on_failure=None, vctx=None): def decorator(fn): @wraps(fn) def inner_fn(*args, **kwargs): vresult = _validate_fn_params(fn, validator, vctx, *a...
{ "repo_name": "YaraslauZhylko/gladiator", "path": "gladiator/decorators.py", "copies": "2", "size": "1780", "license": "bsd-3-clause", "hash": -4088888432393724400, "line_mean": 33.2307692308, "line_max": 89, "alpha_frac": 0.6151685393, "autogenerated": false, "ratio": 3.827956989247312, "confi...
from functools import wraps from inspect import signature from .container import IOCContainer _container = IOCContainer() def _get_filled_arguments(func, *args, **kwargs): function_signature = signature(func) ba = function_signature.bind_partial(*args, **kwargs) return ba.arguments def inject(**dec_...
{ "repo_name": "MichalPodeszwa/pySyringe", "path": "pysyringe/injector.py", "copies": "1", "size": "1170", "license": "mit", "hash": -8239291066462906000, "line_mean": 22.4, "line_max": 72, "alpha_frac": 0.5854700855, "autogenerated": false, "ratio": 3.9130434782608696, "config_test": false, "...
from functools import wraps from inspect import signature from IPython.display import display import matplotlib.pylab as plt import sympy as sp # # General # def disallow_none_kwargs(f): required_kwargs = [] for param in signature(f).parameters.values(): if param.default is None: require...
{ "repo_name": "regiontog/matte3", "path": "common/__init__.py", "copies": "1", "size": "6469", "license": "mit", "hash": 5678344073019216000, "line_mean": 26.6452991453, "line_max": 121, "alpha_frac": 0.495130623, "autogenerated": false, "ratio": 2.462504758279406, "config_test": false, "has_...
from functools import wraps from inspect import signature import warnings def deprecate_param(version_removed, parameter_name, *additional_names): """Create a decorator which warns of parameter deprecation Use this to create a decorator which will watch for use of a deprecated parameter and issue a ``Fut...
{ "repo_name": "civisanalytics/civis-python", "path": "civis/_deprecation.py", "copies": "1", "size": "3219", "license": "bsd-3-clause", "hash": -162660110060183580, "line_mean": 37.3214285714, "line_max": 76, "alpha_frac": 0.5840323082, "autogenerated": false, "ratio": 4.578947368421052, "confi...
from functools import wraps from inspect import signature, Parameter from types import FunctionType from .utils import is_iterable, comma_join, NO_VALUE, arg_to_sql from .query import Cond, QuerySet def binary_operator(func): """ Decorates a function to mark it as a binary operator. """ @wraps(func) ...
{ "repo_name": "Infinidat/infi.clickhouse_orm", "path": "src/infi/clickhouse_orm/funcs.py", "copies": "1", "size": "41249", "license": "bsd-3-clause", "hash": 247532796889790850, "line_mean": 21.701706109, "line_max": 113, "alpha_frac": 0.59843875, "autogenerated": false, "ratio": 3.78570117474302...
from functools import wraps from inspect import signature, Parameter from typing import Tuple, List, Dict, Type class TypeHintError(TypeError): pass class ArgumentTypeHintError(TypeHintError): def __init__( self, argument_name, func_name, expected_type, given_type ) -> None: super()....
{ "repo_name": "potfur/strict-hint", "path": "strict_hint/strict_hint.py", "copies": "1", "size": "3512", "license": "mit", "hash": 1325314122853437400, "line_mean": 28.2666666667, "line_max": 78, "alpha_frac": 0.5390091116, "autogenerated": false, "ratio": 4.335802469135802, "config_test": fals...
from functools import wraps from .inspector import Gadget from .exceptions import PyCondition, PyConditionError from .stage import Stage class Pre(object): def __init__(self): self.funcTable = {} class PreCondition(object): context = Pre() def __init__(self, name): self.name = name ...
{ "repo_name": "streed/pyConditions", "path": "pyconditions/pre.py", "copies": "1", "size": "4219", "license": "apache-2.0", "hash": -5616237128750372000, "line_mean": 26.2193548387, "line_max": 96, "alpha_frac": 0.54041242, "autogenerated": false, "ratio": 3.7336283185840706, "config_test": fal...
from functools import wraps from io import StringIO import sys from flask import request, render_template def templated(template=None): """ Try to render a template for the decorated view Template can be computed from the view name If the view return something else than None or a dict, it will ...
{ "repo_name": "gkrnours/plume", "path": "src/plume/utils.py", "copies": "1", "size": "1351", "license": "mit", "hash": 1568302598820296200, "line_mean": 31.1666666667, "line_max": 76, "alpha_frac": 0.5810510733, "autogenerated": false, "ratio": 4.690972222222222, "config_test": false, "has_no...
from functools import wraps from iso8601 import parse_date from munch import munchify from restkit import BasicAuth, errors, request, Resource from retrying import retry from simplejson import dumps, loads from urlparse import parse_qs, urlparse import logging logger = logging.getLogger(__name__) IGNORE_PARAMS = ('ur...
{ "repo_name": "Leits/openprocurement.client.python", "path": "openprocurement_client/client.py", "copies": "1", "size": "17177", "license": "apache-2.0", "hash": 2524530353353194500, "line_mean": 38.5783410138, "line_max": 189, "alpha_frac": 0.5390347558, "autogenerated": false, "ratio": 4.130079...
from functools import wraps from iso8601 import parse_date from munch import munchify from restkit import BasicAuth, request, Resource from restkit.errors import ResourceNotFound from retrying import retry from simplejson import dumps, loads from urlparse import parse_qs, urlparse import logging from openprocurement_cl...
{ "repo_name": "mykhaly/openprocurement.client.python", "path": "openprocurement_client/client.py", "copies": "1", "size": "21785", "license": "apache-2.0", "hash": -949141567483230700, "line_mean": 37.4215167549, "line_max": 125, "alpha_frac": 0.5239843929, "autogenerated": false, "ratio": 4.2023...
from functools import wraps from itertools import chain from numpy import linspace, meshgrid, sort, unique from scipy.interpolate import griddata """ Generic tools. """ def flatten(iterable): """ Flatten an iterable by one level. """ return chain.from_iterable(iterable) def sift(items, cls): """ Filter out ...
{ "repo_name": "0/SpanishAcquisition", "path": "spacq/tool/box.py", "copies": "2", "size": "2649", "license": "bsd-2-clause", "hash": -417224187081909400, "line_mean": 18.6222222222, "line_max": 90, "alpha_frac": 0.6436391091, "autogenerated": false, "ratio": 2.9531772575250836, "config_test": f...
from functools import wraps from itertools import chain from urllib.parse import urlparse from flask import abort, current_app, g, make_response, request from flask_login import current_user from notifications_utils.field import Field from orderedset._orderedset import OrderedSet from werkzeug.datastructures import Mu...
{ "repo_name": "alphagov/notifications-admin", "path": "app/utils/__init__.py", "copies": "1", "size": "5008", "license": "mit", "hash": 6326252680721185000, "line_mean": 33.0680272109, "line_max": 92, "alpha_frac": 0.6521565495, "autogenerated": false, "ratio": 3.9777601270849883, "config_test"...
from functools import wraps from itertools import chain from .compat import Iterable, Mapping def _with_clone(fn): @wraps(fn) def wrapper(self, *args, **kwargs): clone = self.clone() res = fn(clone, *args, **kwargs) if res is not None: return res return clone r...
{ "repo_name": "anti-social/elasticmagic", "path": "elasticmagic/util.py", "copies": "1", "size": "1607", "license": "apache-2.0", "hash": -3801932500696578600, "line_mean": 21.9571428571, "line_max": 73, "alpha_frac": 0.5930304916, "autogenerated": false, "ratio": 3.7811764705882354, "config_te...
from functools import wraps from itertools import chain from django.contrib import messages from django.contrib.admin.utils import unquote from django.db.models.query import QuerySet from django.http import Http404, HttpResponseRedirect from django.http.response import HttpResponseBase from django.views.generic import...
{ "repo_name": "crccheck/django-object-actions", "path": "django_object_actions/utils.py", "copies": "1", "size": "11068", "license": "apache-2.0", "hash": -418324101309724500, "line_mean": 33.3726708075, "line_max": 102, "alpha_frac": 0.5849295266, "autogenerated": false, "ratio": 4.3990461049284...
from functools import wraps from itertools import chain from django.db.models import Prefetch, Q from django.urls import Resolver404, resolve from django.utils.functional import cached_property from django.utils.translation import ugettext_lazy as _ from rest_framework.authentication import SessionAuthentication from ...
{ "repo_name": "c3nav/c3nav", "path": "src/c3nav/editor/api.py", "copies": "1", "size": "29810", "license": "apache-2.0", "hash": -6476975307162883000, "line_mean": 43.6926536732, "line_max": 119, "alpha_frac": 0.5983227105, "autogenerated": false, "ratio": 4.236180190422055, "config_test": fals...
from functools import wraps from itertools import groupby from operator import itemgetter from collections import defaultdict from flask import request from werkzeug.exceptions import UnsupportedMediaType, NotAcceptable def build_groups(acceptable): """ Build the group information used by the MimeTypeMatcher...
{ "repo_name": "jackfirth/flask-negotiate", "path": "flask_negotiate2.py", "copies": "1", "size": "3060", "license": "mit", "hash": 2941254231374739500, "line_mean": 32.2608695652, "line_max": 78, "alpha_frac": 0.6088235294, "autogenerated": false, "ratio": 4.751552795031056, "config_test": fals...
from functools import wraps from itertools import islice from contextlib import contextmanager from collections import Mapping from copy import copy from .util import Missing, ExplicitNone, threadlocal from .hooks import pre_hook, post_hook, Hook def ContextAttr(name, default=Missing): def fget(self): d...
{ "repo_name": "abetkin/gcontext", "path": "gcontext/base.py", "copies": "1", "size": "4745", "license": "mit", "hash": -4880841745813996000, "line_mean": 24.6486486486, "line_max": 71, "alpha_frac": 0.5527924131, "autogenerated": false, "ratio": 4.455399061032864, "config_test": false, "has_n...
from functools import wraps from itertools import islice from nose.tools import assert_false from nose.tools import assert_in from nose.tools import eq_ from nose.tools import ok_ def _mock_method(function): function_name = function.func_name @wraps(function) def decorator(self, *args, **kwargs): ...
{ "repo_name": "franciscoruiz/python-elm", "path": "tests/utils.py", "copies": "1", "size": "4509", "license": "mit", "hash": -2164039503823307500, "line_mean": 26.1626506024, "line_max": 80, "alpha_frac": 0.5169660679, "autogenerated": false, "ratio": 4.237781954887218, "config_test": false, ...
from functools import wraps from itertools import izip from inspect import getargspec from collections import Callable def async(func): """ Decorator to turn a generator function into an asynchronous function, with yield points corresponding to asynchronous waits (they're also used to convey how asynchrono...
{ "repo_name": "ejones/home", "path": "misc_py/async.py", "copies": "1", "size": "3143", "license": "mit", "hash": 5399555722398393000, "line_mean": 33.1630434783, "line_max": 84, "alpha_frac": 0.6048361438, "autogenerated": false, "ratio": 4.496423462088698, "config_test": false, "has_no_keyw...
from functools import wraps from itertools import starmap __ALL__ = ['overload'] def check_arg(arg, spec): if isinstance(spec, (type, tuple)): return isinstance(arg, spec) elif callable(spec): return spec(arg) else: raise TypeError('Unknown argument spec %s' % repr(spec)) def che...
{ "repo_name": "Suor/overload", "path": "overload.py", "copies": "1", "size": "1077", "license": "bsd-3-clause", "hash": 1412974018618756900, "line_mean": 29.7714285714, "line_max": 84, "alpha_frac": 0.6035283194, "autogenerated": false, "ratio": 3.7922535211267605, "config_test": false, "has_...
from functools import wraps from json import dumps from typing import Any, Callable, Collection, Optional from ..language.ast import Node, OperationType from .visitor import visit, Visitor from .block_string import print_block_string __all__ = ["print_ast"] MAX_LINE_LENGTH = 80 Strings = Collection[str] class Pr...
{ "repo_name": "graphql-python/graphql-core", "path": "src/graphql/language/printer.py", "copies": "1", "size": "13238", "license": "mit", "hash": -8872858023667285000, "line_mean": 29.8578088578, "line_max": 88, "alpha_frac": 0.5644357154, "autogenerated": false, "ratio": 3.9682254196642686, "c...
from functools import wraps from json import JSONDecodeError from uuid import UUID from cerberus import Validator from trellio import HTTPService, TCPService, HTTPView, TCPView from .helpers import json_response class TrellioValidator(Validator): def _validate_type_uuid(self, value): try: UU...
{ "repo_name": "artificilabs/trelliolibs", "path": "trelliolibs/utils/decorators.py", "copies": "1", "size": "2599", "license": "mit", "hash": -370061084563326200, "line_mean": 36.6666666667, "line_max": 119, "alpha_frac": 0.561754521, "autogenerated": false, "ratio": 4.725454545454546, "config_...
from functools import wraps from jwt.exceptions import InvalidIssuerError, InvalidTokenError from .asap import _process_asap_token, _verify_issuers from .utils import SettingsDict def _with_asap(func=None, backend=None, issuers=None, required=True, subject_should_match_issuer=None): if backend is ...
{ "repo_name": "atlassian/asap-authentication-python", "path": "atlassian_jwt_auth/frameworks/common/decorators.py", "copies": "1", "size": "3338", "license": "mit", "hash": 9004969093819916000, "line_mean": 30.4905660377, "line_max": 77, "alpha_frac": 0.5913720791, "autogenerated": false, "ratio"...
from functools import wraps from limits.util import parse, parse_many from .util import LimitWrapper DECORATED = {} EXEMPT = [] def limit(limit_value, key_function=None, per_method=False): """ decorator to be used for rate limiting individual views :param limit_value: rate limit string or a callable that...
{ "repo_name": "alisaifee/djlimiter", "path": "djlimiter/decorators.py", "copies": "1", "size": "2702", "license": "mit", "hash": -9078779551613909000, "line_mean": 31.5542168675, "line_max": 84, "alpha_frac": 0.6028867506, "autogenerated": false, "ratio": 4.169753086419753, "config_test": false...
from functools import wraps from locale import setlocale from django.db.models.signals import ( post_delete, post_init, post_save, pre_delete, pre_init, pre_save, ) def signal_connect(cls): """ Class decorator that automatically connects pre_save / post_save signals on a model cla...
{ "repo_name": "medunigraz/outpost", "path": "src/outpost/django/base/decorators.py", "copies": "1", "size": "1991", "license": "bsd-2-clause", "hash": -3762769164526640000, "line_mean": 24.8571428571, "line_max": 79, "alpha_frac": 0.5976896032, "autogenerated": false, "ratio": 3.700743494423792, ...
from functools import wraps from logging import getLogger from shutil import move, copy from core.exceptions import RestoreError from core.tokenizer import Tokenizer from os.path import join, basename, isfile, expanduser from settings.settings import CONFIG_FILES, REPO_PATH, FILE_NAME_TO_COMMIT from utils.helpers impor...
{ "repo_name": "idjaw/dot-manager", "path": "app/core/restore.py", "copies": "1", "size": "2325", "license": "mit", "hash": -3439930974100434000, "line_mean": 32.2142857143, "line_max": 80, "alpha_frac": 0.5853763441, "autogenerated": false, "ratio": 4.09330985915493, "config_test": true, "has...
from functools import wraps from logging import getLogger from mongosql import CrudViewMixin, StrictCrudHelper, StrictCrudHelperSettingsDict, saves_relations from . import models from flask import request, g, jsonify from flask_jsontools import jsonapi, RestfulView logger = getLogger(__name__) def passthrough_deco...
{ "repo_name": "kolypto/py-mongosql", "path": "tests/crud_view.py", "copies": "1", "size": "9409", "license": "bsd-2-clause", "hash": 6901548853220053000, "line_mean": 33.3394160584, "line_max": 142, "alpha_frac": 0.5928366458, "autogenerated": false, "ratio": 4.269056261343013, "config_test": f...
from functools import wraps from logging import getLogger logger = getLogger(__name__) def set_parameter(function): @wraps(function) def _set_parameter(self, name, value, **kwargs): if name not in self.parameters.index: logger.error("Parameter name {} does not exist, please choose " ...
{ "repo_name": "gwtsa/gwtsa", "path": "pastas/decorators.py", "copies": "1", "size": "1587", "license": "mit", "hash": -652258072991897000, "line_mean": 29.5192307692, "line_max": 79, "alpha_frac": 0.6049149338, "autogenerated": false, "ratio": 4.007575757575758, "config_test": false, "has_no_...
from functools import wraps from lxml.etree import ParseError from requests import RequestException from _exception import http_404, http_301 def ensure_index(fn): """ Decorator for the handle() method of any handler. Ensures that indexes requested without a trailing slash are redirected to a version ...
{ "repo_name": "teamfruit/defend_against_fruit", "path": "pypi_redirect/pypi_redirect/server_app/handler/_utils.py", "copies": "1", "size": "1574", "license": "apache-2.0", "hash": 8869946685771187000, "line_mean": 28.1481481481, "line_max": 74, "alpha_frac": 0.6296060991, "autogenerated": false, ...
from functools import wraps from lxml import etree import logging from django.http import HttpResponse logger = logging.getLogger(__name__) #I only use this decorator with REST calls so if failed I respond with an XML def http_basic_auth(func): @wraps(func) def _decorator(request, *args, **kwargs): fr...
{ "repo_name": "Si-elegans/Web-based_GUI_Tools", "path": "mysite/my_decorators.py", "copies": "1", "size": "1842", "license": "apache-2.0", "hash": -6688727487614615000, "line_mean": 39.0434782609, "line_max": 90, "alpha_frac": 0.6026058632, "autogenerated": false, "ratio": 4.593516209476309, "c...
from functools import wraps from lxml import html import json import logging import re import time import urllib import urllib2 MAXRETRIES = 3 RETRYSLEEP = 5 class Connection: def __init__(self, hostname, baseurl, opener, auth_cookies): self.host = hostname self.opener = opener self.auth_cookies = aut...
{ "repo_name": "mhellmic/bamboo-automate", "path": "lib/requests.py", "copies": "1", "size": "4164", "license": "apache-2.0", "hash": 5376310496811034000, "line_mean": 28.5319148936, "line_max": 99, "alpha_frac": 0.636167147, "autogenerated": false, "ratio": 3.3853658536585365, "config_test": fa...
from functools import wraps from .main import * def antibrute_login(func): """ Wrapper for login view. This will take care of all the checks and displaying lockout page """ @wraps(func) def wrap_login(request, *args, **kwargs): # TODO: IP check goes here here username = '' ...
{ "repo_name": "maulik13/django-antibrute", "path": "antibrute/decorators.py", "copies": "1", "size": "1036", "license": "mit", "hash": -6561699092029706000, "line_mean": 31.375, "line_max": 79, "alpha_frac": 0.6013513514, "autogenerated": false, "ratio": 4.4655172413793105, "config_test": false...
from functools import wraps from mako.lookup import TemplateLookup from distill import PY2 import json from distill.exceptions import HTTPInternalServerError from distill.response import Response class RenderFactory(object): """ This class provides a wrapper for handling rendering operations """ _fac...
{ "repo_name": "Dreae/Distill", "path": "distill/renderers.py", "copies": "1", "size": "4584", "license": "mit", "hash": -4680932281494713000, "line_mean": 33.7348484848, "line_max": 95, "alpha_frac": 0.6106020942, "autogenerated": false, "ratio": 4.765072765072765, "config_test": false, "has_...
from functools import wraps from ..mapping import EpistasisMap from numpy import random class DistributionException(Exception): """""" class SimulatedEpistasisMap(EpistasisMap): """Just like an epistasis map, but with extra methods for setting epistatic coefficients """ def __init__(self, gpm, df=...
{ "repo_name": "harmslab/epistasis", "path": "epistasis/simulate/mapping.py", "copies": "2", "size": "1482", "license": "unlicense", "hash": -665115553734013400, "line_mean": 33.488372093, "line_max": 97, "alpha_frac": 0.6322537112, "autogenerated": false, "ratio": 4.174647887323943, "config_tes...
from functools import wraps from math import ceil from flask import url_for, request, current_app def _get_page_link(page_number): return url_for(request.url_rule.endpoint, page=page_number, _external=True) class PaginationFunctions: @staticmethod def paginate(view_function): @wraps(view_functio...
{ "repo_name": "mass-project/mass_server", "path": "mass_flask_core/utils/pagination_functions.py", "copies": "1", "size": "1200", "license": "mit", "hash": 5713814359072318000, "line_mean": 37.7096774194, "line_max": 113, "alpha_frac": 0.5991666667, "autogenerated": false, "ratio": 4.013377926421...
from functools import wraps from math import ceil import numpy as np import scipy.sparse as sp def chunks(iterable, chunk_size): """ Splits iterable objects into chunk of fixed size. The last chunk may be truncated. """ chunk = [] for item in iterable: chunk.append(item) if len(chu...
{ "repo_name": "cheral/orange3-text", "path": "orangecontrib/text/util.py", "copies": "1", "size": "1703", "license": "bsd-2-clause", "hash": 9068441106863198000, "line_mean": 26.9180327869, "line_max": 93, "alpha_frac": 0.5819142689, "autogenerated": false, "ratio": 4.054761904761905, "config_t...
from functools import wraps from memsql_framework.util.attr_dict import AttrDict from memsql_framework.ui import exceptions ENDPOINTS = {} def endpoint(name, schema=None, methods=None): def _deco(wrapped): @wraps(wrapped) def _wrap(root, params): if schema is not None: ...
{ "repo_name": "memsql/memsql-mesos", "path": "memsql_framework/ui/api/endpoints.py", "copies": "1", "size": "1095", "license": "apache-2.0", "hash": -3110128063949269500, "line_mean": 27.8157894737, "line_max": 87, "alpha_frac": 0.6365296804, "autogenerated": false, "ratio": 3.9388489208633093, ...
from functools import wraps from mock import patch from nose.tools import nottest from . import (get_all_test_configs, resources_for_test_config, specs_for_test_config, assembled_specs_for_test_config, nginx_config_for_test_config, docker_compose_yaml_for_test_config) from dusty.compiler import spec_as...
{ "repo_name": "gamechanger/dusty", "path": "tests/unit/compiler/test_test_cases.py", "copies": "1", "size": "16336", "license": "mit", "hash": -2299166165942645000, "line_mean": 48.6534954407, "line_max": 116, "alpha_frac": 0.3213761019, "autogenerated": false, "ratio": 5.202547770700637, "conf...
from functools import wraps from multiprocessing import Process, get_context from multiprocessing.queues import Queue from threading import Thread import time from multiprocessing import Lock class BlockedQueue(Queue): def __init__(self, maxsize=-1, block=True, timeout=None): self.block = block s...
{ "repo_name": "samuelsh/pyFstress", "path": "logger/asynx.py", "copies": "2", "size": "3673", "license": "mit", "hash": -6921852615160614000, "line_mean": 21.3963414634, "line_max": 72, "alpha_frac": 0.5551320447, "autogenerated": false, "ratio": 3.919957310565635, "config_test": true, "has_n...
from functools import wraps from multiprocessing import Process import webbrowser from .utils import processing_func_name def processing_function(func): """Decorator for turning Sketch methods into Processing functions. Marks the function it's decorating as a processing function by camel casing the name...
{ "repo_name": "croach/processing.py", "path": "lib/p5/sketch.py", "copies": "2", "size": "3501", "license": "mit", "hash": 2196176670442872800, "line_mean": 25.9307692308, "line_max": 78, "alpha_frac": 0.606398172, "autogenerated": false, "ratio": 4.109154929577465, "config_test": false, "has...
from functools import wraps from .named import namedtuple from .ast import * @namedtuple def Intermediate(kind, originalindex, value): assert kind in {'bytecode', 'if', 'for', 'do', 'label'} def get_labels(bc): for i, b in enumerate(bc): if b[0].startswith('jump'): yield b[1] def into_lis...
{ "repo_name": "gvx/isle", "path": "read_bytecode.py", "copies": "1", "size": "9272", "license": "isc", "hash": -8009722888555481000, "line_mean": 38.9655172414, "line_max": 127, "alpha_frac": 0.4762726488, "autogenerated": false, "ratio": 3.90071518721077, "config_test": false, "has_no_keywor...
from functools import wraps from operator import attrgetter from django.db import connections, transaction, IntegrityError from django.db.models import signals, sql from django.db.models.sql.constants import GET_ITERATOR_CHUNK_SIZE from django.utils.datastructures import SortedDict class ProtectedError(IntegrityErro...
{ "repo_name": "skevy/django", "path": "django/db/models/deletion.py", "copies": "2", "size": "10834", "license": "bsd-3-clause", "hash": -8947212117274516000, "line_mean": 39.2750929368, "line_max": 84, "alpha_frac": 0.5926712202, "autogenerated": false, "ratio": 4.431083844580777, "config_test...
from functools import wraps from operator import attrgetter from django.db import connections, transaction, IntegrityError from django.db.models import signals, sql from django.utils.datastructures import SortedDict from django.utils import six class ProtectedError(IntegrityError): def __init__(self, msg, protec...
{ "repo_name": "vsajip/django", "path": "django/db/models/deletion.py", "copies": "1", "size": "11445", "license": "bsd-3-clause", "hash": 4599691006005184500, "line_mean": 39.7295373665, "line_max": 86, "alpha_frac": 0.5966797728, "autogenerated": false, "ratio": 4.453307392996109, "config_test...
from functools import wraps from os import makedirs from os.path import isdir from future.utils import raise_with_traceback from os import path from requests import ( get as http_get_request, HTTPError, ) from requests.exceptions import ( ConnectionError, ConnectTimeout ) from screener.exceptions impo...
{ "repo_name": "netanelravid/screener", "path": "screener/utils/decorators.py", "copies": "1", "size": "3900", "license": "apache-2.0", "hash": -4352944230025209000, "line_mean": 30.7073170732, "line_max": 108, "alpha_frac": 0.6030769231, "autogenerated": false, "ratio": 4.367301231802911, "conf...
from functools import wraps from os.path import abspath import click from .interact.setup_user import setup_user from . import application from dateutil.parser import parse as parse_datetime from datetime import datetime, timedelta from dateutil.tz import tzlocal dir_option = click.option( '--dir', default=abspat...
{ "repo_name": "srossross/stable.world", "path": "stable_world/utils.py", "copies": "1", "size": "2474", "license": "bsd-2-clause", "hash": -2973460672225561600, "line_mean": 21.2882882883, "line_max": 63, "alpha_frac": 0.6289409863, "autogenerated": false, "ratio": 3.6064139941690962, "config_t...