text stringlengths 0 1.05M | meta dict |
|---|---|
from functools import wraps
__all__ = ['classproperty', 'validatetype']
class classproperty(object):
def __init__(self, getter):
self.getter = getter
def __get__(self, instance, owner):
return self.getter(owner)
def validatetype(pos, typ, exc=TypeError, msg=None, format_args=None):
""... | {
"repo_name": "alok1974/compage",
"path": "src/compage/decorator.py",
"copies": "1",
"size": "1848",
"license": "mit",
"hash": 7095520478013080000,
"line_mean": 35.2352941176,
"line_max": 77,
"alpha_frac": 0.5633116883,
"autogenerated": false,
"ratio": 4.666666666666667,
"config_test": false,
... |
from functools import wraps
class AssemblaObject(object):
"""
Proxies getitem calls (eg: `instance['id']`) to a dictionary `instance.data['id']`.
"""
def __init__(self, data={}):
self.data = data
def __getitem__(self, key):
return self.data[key]
def __setitem__(self, key, val... | {
"repo_name": "markfinger/assembla",
"path": "assembla/lib.py",
"copies": "1",
"size": "2289",
"license": "mit",
"hash": -4750020619272711000,
"line_mean": 29.1315789474,
"line_max": 102,
"alpha_frac": 0.5351681957,
"autogenerated": false,
"ratio": 4.207720588235294,
"config_test": false,
"ha... |
from functools import wraps
class AttributeDescription(object):
def __init__(self, text, value=None, *args, **kwargs):
self.name = None
self.text = text
self.value = value
def __call__(self, attr, model):
self.name = attr
def __get__(self, obj, type=None): # pragma: no co... | {
"repo_name": "ryfeus/lambda-packs",
"path": "Spacy/source2.7/thinc/describe.py",
"copies": "1",
"size": "2948",
"license": "mit",
"hash": 8473119189768093000,
"line_mean": 22.9674796748,
"line_max": 64,
"alpha_frac": 0.5712347354,
"autogenerated": false,
"ratio": 3.73637515842839,
"config_test... |
from functools import wraps
class cached_property(object):
"""
A property that is only computed once per instance and then replaces itself
with an ordinary attribute. Deleting the attribute resets the property.
Source: https://github.com/bottlepy/bottle/commit/fa7733e075da0d790d809aa3d2f53071897e6f76
... | {
"repo_name": "jhgg/graphene",
"path": "graphene/utils.py",
"copies": "1",
"size": "2444",
"license": "mit",
"hash": 5405893544731956000,
"line_mean": 27.4186046512,
"line_max": 94,
"alpha_frac": 0.5793780687,
"autogenerated": false,
"ratio": 3.961102106969206,
"config_test": false,
"has_no_k... |
from functools import wraps
class ChainableBase(object):
def _generate(self):
s = self.__class__.__new__(self.__class__)
s.__dict__ = self.__dict__.copy()
return s
def chain(func):
@wraps(func)
def decorator(self, *args, **kw):
self = self._generate()
func(self, *... | {
"repo_name": "christippett/django-postmark-inbound",
"path": "postmark_inbound/utils.py",
"copies": "1",
"size": "1894",
"license": "mit",
"hash": 5015918507287738000,
"line_mean": 31.1016949153,
"line_max": 162,
"alpha_frac": 0.6040126716,
"autogenerated": false,
"ratio": 4.354022988505747,
"... |
from functools import wraps
class Command(object):
def __init__(self, name, func, arg_names):
self.name = name
self.func = func
self.arg_names = arg_names
def __call__(self, arg_dict):
values = []
for name in self.arg_names:
if name == '*':
... | {
"repo_name": "fespino/climate",
"path": "climate.py",
"copies": "1",
"size": "2007",
"license": "mit",
"hash": -8417562928656906000,
"line_mean": 26.4931506849,
"line_max": 80,
"alpha_frac": 0.5645241654,
"autogenerated": false,
"ratio": 4.014,
"config_test": false,
"has_no_keywords": false,... |
from functools import wraps
class MetaMachine(type):
def __new__(cls, name, bases, d):
state = d.get('initial_state')
if state == None:
for base in bases:
try:
state = base.initial_state
break
except AttributeErr... | {
"repo_name": "kyleconroy/statemachine",
"path": "statemachine.py",
"copies": "1",
"size": "3061",
"license": "mit",
"hash": 474971479178246900,
"line_mean": 29.3069306931,
"line_max": 79,
"alpha_frac": 0.5775890232,
"autogenerated": false,
"ratio": 4.142083897158322,
"config_test": false,
"h... |
from functools import wraps
class _PluginManager(object):
def __init__(self):
self._registered_plugins = []
self._cached_base_callbacks = {}
self._built_functions = {}
def register(self, *plugins):
"""
Makes it possible to register your plugin.
"""
self... | {
"repo_name": "srusskih/SublimeJEDI",
"path": "dependencies/jedi/plugins/__init__.py",
"copies": "6",
"size": "1453",
"license": "mit",
"hash": 4002873228695675400,
"line_mean": 29.914893617,
"line_max": 68,
"alpha_frac": 0.5636613902,
"autogenerated": false,
"ratio": 4.875838926174497,
"config... |
from functools import wraps
class SafeDict(dict):
"""
A dict that a "get" method that allows to use a path-like reference to its subdict values.
For example with a dict like {"key": {"subkey": {"subsubkey": "value"}}}
you can use a string 'key|subkey|subsubkey' to get the 'value'.
The default va... | {
"repo_name": "egnyte/gitlabform",
"path": "gitlabform/gitlabform/processors/util/decorators.py",
"copies": "1",
"size": "1277",
"license": "mit",
"hash": -7889891810961765000,
"line_mean": 28.0227272727,
"line_max": 111,
"alpha_frac": 0.5967110415,
"autogenerated": false,
"ratio": 4.119354838709... |
from functools import wraps
def bound(method):
@wraps(method)
def bound_method(self, *args, **kwargs):
return self.bind(method, args, kwargs)
return bound_method
class MathOp(object):
def __init__(self, value=None, is_nan=False):
self.value = value
self.is_nan = is_nan
d... | {
"repo_name": "jorgenschaefer/monads-for-normal-programmers",
"path": "monads/mathop/step2_2.py",
"copies": "1",
"size": "1043",
"license": "bsd-2-clause",
"hash": -5382719913850946000,
"line_mean": 22.1777777778,
"line_max": 51,
"alpha_frac": 0.5637583893,
"autogenerated": false,
"ratio": 3.6089... |
from functools import wraps
def bound(method):
@wraps(method)
def bound_method(self, *args, **kwargs):
return self.bind(method, args, kwargs)
return bound_method
class MaybeMonad(object):
is_nothing = False
def bind(self, method, args, kwargs):
if self.is_nothing:
re... | {
"repo_name": "jorgenschaefer/monads-for-normal-programmers",
"path": "monads/mathop/step3.py",
"copies": "1",
"size": "1169",
"license": "bsd-2-clause",
"hash": 8788106227948160000,
"line_mean": 19.5087719298,
"line_max": 48,
"alpha_frac": 0.5791274594,
"autogenerated": false,
"ratio": 3.6304347... |
from functools import wraps
def cached_class(klass):
"""Decorator to cache class instances by constructor arguments.
We "tuple-ize" the keyword arguments dictionary since
dicts are mutable; keywords themselves are strings and
so are always hashable, but if any arguments (keyword
or positional... | {
"repo_name": "ActiveState/code",
"path": "recipes/Python/577998_Cached_Class/recipe-577998.py",
"copies": "1",
"size": "2088",
"license": "mit",
"hash": -2413890014548571000,
"line_mean": 39.9411764706,
"line_max": 67,
"alpha_frac": 0.5421455939,
"autogenerated": false,
"ratio": 4.99521531100478... |
from functools import wraps
def cachedprop(fn):
'''Decorator which creates a cached property.'''
@wraps(fn)
def get(self):
cache_name = '__' + fn.__name__ + '__cache'
try:
return self.__dict__[cache_name]
except KeyError:
ret = fn(self)
self.__... | {
"repo_name": "Samsung/ADBI",
"path": "idk/common/deco.py",
"copies": "1",
"size": "2437",
"license": "apache-2.0",
"hash": -5570610554295112000,
"line_mean": 26.393258427,
"line_max": 111,
"alpha_frac": 0.5666803447,
"autogenerated": false,
"ratio": 4.479779411764706,
"config_test": false,
"... |
from functools import wraps
def cache_forever(f):
f.cache = {}
@wraps(f)
def inner(*args):
if args not in f.cache:
f.cache[args] = f(*args)
return f.cache[args]
return inner
def property_cache_forever(f):
f.cached = None
@wraps(f)
def inner(self):
i... | {
"repo_name": "Dentosal/python-sc2",
"path": "sc2/cache.py",
"copies": "1",
"size": "1433",
"license": "mit",
"hash": 7077598009132946000,
"line_mean": 21.746031746,
"line_max": 123,
"alpha_frac": 0.5799023029,
"autogenerated": false,
"ratio": 3.5646766169154227,
"config_test": false,
"has_no... |
from functools import wraps
def chainable_method(fn):
@wraps(fn)
def inner(self, *args, **kwargs):
fn(self, *args, **kwargs)
return self
return inner
class Sortable(object):
def sort(self, pattern=None, limit=None, offset=None, get_pattern=None,
ordering=None, alpha=True... | {
"repo_name": "johndlong/walrus",
"path": "walrus/containers.py",
"copies": "1",
"size": "25627",
"license": "mit",
"hash": 9207946388598180000,
"line_mean": 29.9879081016,
"line_max": 79,
"alpha_frac": 0.5635462598,
"autogenerated": false,
"ratio": 4.046581399021001,
"config_test": false,
"h... |
from functools import wraps
def csp_exempt(f):
@wraps(f)
def _wrapped(*a, **kw):
r = f(*a, **kw)
r._csp_exempt = True
return r
return _wrapped
def csp_update(**kwargs):
update = dict((k.lower().replace('_', '-'), v) for k, v in kwargs.items())
def decorator(f):
@... | {
"repo_name": "graingert/django-csp",
"path": "csp/decorators.py",
"copies": "2",
"size": "1105",
"license": "bsd-3-clause",
"hash": -3387153826585380400,
"line_mean": 21.5510204082,
"line_max": 79,
"alpha_frac": 0.4859728507,
"autogenerated": false,
"ratio": 3.611111111111111,
"config_test": f... |
from functools import wraps
def lazy_property(fct, name=None):
name = name or fct.__name__
attr_name = '_' + name
if attr_name == '_<lambda>':
raise Exception("cannot assign <lambda> to lazy property")
@property
@wraps(fct)
def _wrapper(self):
if not hasattr(self, attr_name):
... | {
"repo_name": "bpsmith/tia",
"path": "tia/util/decorator.py",
"copies": "1",
"size": "1339",
"license": "bsd-3-clause",
"hash": 9160870729775040000,
"line_mean": 30.1627906977,
"line_max": 114,
"alpha_frac": 0.6064227035,
"autogenerated": false,
"ratio": 4.264331210191083,
"config_test": false,... |
from functools import wraps
def memoized(f):
"""
A simple memoization decorator.
"""
cache = f.cache = {}
@wraps(f)
def wrapper(*args, **kwargs):
key = (args, frozenset(kwargs.items()))
if key in cache:
return cache[key]
result = f(*args, **kwargs)
cache[key] = result
return result
return wr... | {
"repo_name": "0/Boltzmannizer",
"path": "boltzmannizer/tools/misc.py",
"copies": "1",
"size": "1396",
"license": "mit",
"hash": -5229988607004490000,
"line_mean": 18.3888888889,
"line_max": 75,
"alpha_frac": 0.6676217765,
"autogenerated": false,
"ratio": 3.1799544419134396,
"config_test": fals... |
from functools import wraps
def _restore_languages_on_generator_exit(method):
@wraps(method)
def wrapped(self, *args, **kwargs):
stored_languages = self.languages[:]
for language in method(self, *args, **kwargs):
yield language
else:
self.languages[:] = stored_l... | {
"repo_name": "scrapinghub/dateparser",
"path": "dateparser/search/detection.py",
"copies": "1",
"size": "2609",
"license": "bsd-3-clause",
"hash": 215689389633639360,
"line_mean": 36.2714285714,
"line_max": 101,
"alpha_frac": 0.6646224607,
"autogenerated": false,
"ratio": 4.59330985915493,
"co... |
from functools import wraps
def split_in_size_n(l, n):
return [l[i:i + n] for i in range(0, len(l), n)]
def reg_to_memfunc(f, in_size, out_size, per_reg=256):
""" Makes a function that operates on registers use memory instead. """
# To prevent circular imports
from .instructions import vmovdqu
... | {
"repo_name": "joostrijneveld/bitpermutations",
"path": "bitpermutations/utils.py",
"copies": "1",
"size": "1482",
"license": "cc0-1.0",
"hash": -5111207290359574000,
"line_mean": 26.9622641509,
"line_max": 75,
"alpha_frac": 0.5371120108,
"autogenerated": false,
"ratio": 3.375854214123007,
"con... |
from functools import wraps
def stub(fn):
"""
Used for unimplemeted parent class methods.
Warns about it upon usage
:param fn: method
"""
fn.__stub__ = True
@wraps(fn)
def wrapper(*args, **kwargs):
raise NotImplemented("Method {0} is not implemented. Method desc: {1}".format(fn... | {
"repo_name": "zaibacu/wutu",
"path": "wutu/decorators.py",
"copies": "1",
"size": "1265",
"license": "mit",
"hash": -835436842193281900,
"line_mean": 29.119047619,
"line_max": 111,
"alpha_frac": 0.628458498,
"autogenerated": false,
"ratio": 3.940809968847352,
"config_test": false,
"has_no_ke... |
from functools import wraps
def type_name(x):
return x.__class__.__name__
def check_equal(a, b):
assert a == b, '{}:{} != {}:{}'.format(a, type_name(a), b, type_name(b))
def checker_fn(fn_apply, fn_assert):
def inner(a, b):
return fn_assert(fn_apply(*a), b)
return inner
def gente... | {
"repo_name": "naiquevin/nozzle",
"path": "nozzle.py",
"copies": "1",
"size": "1237",
"license": "mit",
"hash": 2736438287001176600,
"line_mean": 24.2448979592,
"line_max": 76,
"alpha_frac": 0.510105093,
"autogenerated": false,
"ratio": 3.5042492917847023,
"config_test": false,
"has_no_keywor... |
from functools import wraps
def use_select2(view_func):
"""Use this decorator on the dispatch method of a TemplateView subclass
to enable the inclusion of the select2 js library at the base template.
Example:
@use_select2
def dispatch(self, request, *args, **kwargs):
return super(MyView,... | {
"repo_name": "qedsoftware/commcare-hq",
"path": "corehq/apps/style/decorators.py",
"copies": "1",
"size": "9771",
"license": "bsd-3-clause",
"hash": -8744902030891091000,
"line_mean": 31.1414473684,
"line_max": 79,
"alpha_frac": 0.6639033876,
"autogenerated": false,
"ratio": 3.7194518462124098,
... |
from functools import wraps
def xframe_options_deny(view_func):
"""
Modifies a view function so its response has the X-Frame-Options HTTP
header set to 'DENY' as long as the response doesn't already have that
header set.
e.g.
@xframe_options_deny
def some_view(request):
...
"... | {
"repo_name": "mattseymour/django",
"path": "django/views/decorators/clickjacking.py",
"copies": "10",
"size": "1580",
"license": "bsd-3-clause",
"hash": 7710506650923923000,
"line_mean": 25.7796610169,
"line_max": 75,
"alpha_frac": 0.6259493671,
"autogenerated": false,
"ratio": 3.744075829383886... |
from functools import wraps
def xframe_options_deny(view_func):
"""
Modify a view function so its response has the X-Frame-Options HTTP
header set to 'DENY' as long as the response doesn't already have that
header set. Usage:
@xframe_options_deny
def some_view(request):
...
"""
... | {
"repo_name": "arun6582/django",
"path": "django/views/decorators/clickjacking.py",
"copies": "125",
"size": "1565",
"license": "bsd-3-clause",
"hash": 256381051921515870,
"line_mean": 28.5283018868,
"line_max": 78,
"alpha_frac": 0.6338658147,
"autogenerated": false,
"ratio": 3.817073170731707,
... |
from functools import wraps
def xframe_sameorigin(view_fn):
@wraps(view_fn)
def _wrapped_view(request, *args, **kwargs):
response = view_fn(request, *args, **kwargs)
response['X-Frame-Options'] = 'SAMEORIGIN'
return response
return _wrapped_view
def xframe_allow(view_fn):
@wr... | {
"repo_name": "jsocol/commonware",
"path": "commonware/response/decorators.py",
"copies": "1",
"size": "1328",
"license": "bsd-3-clause",
"hash": 7496949868046068000,
"line_mean": 26.6666666667,
"line_max": 56,
"alpha_frac": 0.6129518072,
"autogenerated": false,
"ratio": 3.550802139037433,
"con... |
from functools import wraps
_enable_pluggable_decorators = True
def pluggable(*decorators):
""" Pluggable decorators
@pluggable(
require_POST,
login_required,
)
def some_view(request):
''' Your view func here. '''
## Decorated behavior.
res = some_view(request)
... | {
"repo_name": "hirokiky/wraptools",
"path": "wraptools/pluggable.py",
"copies": "1",
"size": "2439",
"license": "mit",
"hash": 7874435099790849000,
"line_mean": 23.1485148515,
"line_max": 89,
"alpha_frac": 0.561295613,
"autogenerated": false,
"ratio": 4.234375,
"config_test": false,
"has_no_k... |
from functools import wraps
from django.core.cache import cache
from django.shortcuts import get_object_or_404
from django.views.generic.simple import direct_to_template
from django.http import HttpResponseRedirect, Http404, HttpResponse
from django.core.exceptions import PermissionDenied
from django.core.urlresolve... | {
"repo_name": "ojarva/password-safe-django",
"path": "passwordsafe/passwords/views.py",
"copies": "1",
"size": "4370",
"license": "mit",
"hash": 6172048626245807000,
"line_mean": 37.3333333333,
"line_max": 189,
"alpha_frac": 0.6750572082,
"autogenerated": false,
"ratio": 3.754295532646048,
"con... |
from functools import wraps
# generic container used to denote zset
class zset():
def __init__(self, primitive):
self.primitive = primitive
def check_field(func):
@wraps(func)
def _wrapper(self_cls, field, *args, **kwargs):
if not field in self_cls.fields:
raise TypeError('in... | {
"repo_name": "proteneer/apollo",
"path": "apollo.py",
"copies": "1",
"size": "19600",
"license": "mit",
"hash": -3256364899504813000,
"line_mean": 38.595959596,
"line_max": 79,
"alpha_frac": 0.5711734694,
"autogenerated": false,
"ratio": 3.9918533604887982,
"config_test": false,
"has_no_keyw... |
from functools import wraps
#########################################################
# _correct_type, _multi_type_fix and _single_type_fix #
# are all meant to be helper functions, they are not #
# meant to be used outside this modole #
#########################################################
... | {
"repo_name": "fredgj/typecorrector",
"path": "typecorrector/corrector.py",
"copies": "1",
"size": "1956",
"license": "mit",
"hash": -6063045079613811000,
"line_mean": 32.724137931,
"line_max": 87,
"alpha_frac": 0.5823108384,
"autogenerated": false,
"ratio": 3.8579881656804735,
"config_test": f... |
from functools import wraps
##################################################################
# The Monad meta design pattern.
class Monad(object):
def bind(self, method, args, kwargs):
return method(self, *args, **kwargs)
def bound(method):
@wraps(method)
def bound_method(self, *args, **kwarg... | {
"repo_name": "jorgenschaefer/monads-for-normal-programmers",
"path": "monads/mathop/step4.py",
"copies": "1",
"size": "1786",
"license": "bsd-2-clause",
"hash": 236182415988419420,
"line_mean": 22.5,
"line_max": 66,
"alpha_frac": 0.5414333707,
"autogenerated": false,
"ratio": 4.0225225225225225,... |
from functools import wraps
"""
The following example creates a Chart.js chart with id of 'mychart' width and height of 400px.
Two datasets are created for '# of apples' and '# of bananas'. Both are 'bar' charts.
At '17:51' the value for the '# of apples' are 12, and at '17:54' it is 5.
At '17:51' the value for the '#... | {
"repo_name": "danielrenes/data-visualization",
"path": "data_visualization/chartjs.py",
"copies": "1",
"size": "5562",
"license": "mit",
"hash": -3323838769291802600,
"line_mean": 27.6701030928,
"line_max": 100,
"alpha_frac": 0.5251708019,
"autogenerated": false,
"ratio": 3.7581081081081082,
"... |
from functools import wraps
__version__ = "0.1"
class Multimple(object):
_IMPL_ATTR_NAME = "_multimple_current"
def __init__(self, func, default):
super(Multimple, self).__init__()
self._impls = {
default: func
}
self._default = default
self._name = func... | {
"repo_name": "n9code/multimple",
"path": "multimple/__init__.py",
"copies": "1",
"size": "1886",
"license": "mit",
"hash": 5643768464516046000,
"line_mean": 22.575,
"line_max": 65,
"alpha_frac": 0.5281018028,
"autogenerated": false,
"ratio": 4.325688073394495,
"config_test": false,
"has_no_k... |
from functools import wraps
__version__ = "0.1"
def get_version():
return __version__
def next_version():
_v = __version__.split('.')
_v[-1] = str(int(_v[-1]) + 1)
return '.'.join(_v)
def validate_request(validator):
def _json_selector(obj, current_selector):
json_dict = obj.get_json... | {
"repo_name": "laco/flask-gladiator",
"path": "flask_gladiator/__init__.py",
"copies": "1",
"size": "2302",
"license": "bsd-3-clause",
"hash": -391807248353248830,
"line_mean": 29.2894736842,
"line_max": 71,
"alpha_frac": 0.5638575152,
"autogenerated": false,
"ratio": 3.9689655172413794,
"confi... |
from functools import wraps
RED = '\033[91m'
BLUE = '\033[94m'
BOLD = '\033[1m'
END = '\033[0m'
def _default_handler(e, *args, **kwargs):
pass
def silence(target_exceptions:list, exception_handler=_default_handler):
def decor(func):
@wraps(func)
def wrapper(*args, **kwargs):
try... | {
"repo_name": "kashifrazzaqui/again",
"path": "again/decorate.py",
"copies": "1",
"size": "7286",
"license": "mit",
"hash": -8577842810936702000,
"line_mean": 35.435,
"line_max": 119,
"alpha_frac": 0.4733735932,
"autogenerated": false,
"ratio": 4.545227698066126,
"config_test": false,
"has_no... |
from functools import wraps
try:
import simplejson as json
except ImportError:
import json
from tornado.web import HTTPError, RequestHandler
from pycloudia.uitls.decorators import generate_list, generate_dict
from pycloudia.uitls.defer import maybe_deferred, return_value, inline_callbacks
def http_request_... | {
"repo_name": "cordis/pycloudia-chat",
"path": "pyligaforex/rest/decorators.py",
"copies": "1",
"size": "3030",
"license": "mit",
"hash": -6624981193899774000,
"line_mean": 28.1346153846,
"line_max": 80,
"alpha_frac": 0.601650165,
"autogenerated": false,
"ratio": 4.04,
"config_test": false,
"... |
from functools import wraps
try: # Python 2.*
from django.utils.encoding import force_unicode
except ImportError: # Python 3.*
from django.utils.encoding import force_text
force_unicode = force_text
try: # Django >= 1.4
from django.utils import timezone
except ImportError: # Django < 1.4
from d... | {
"repo_name": "ProDG/django-redis-sessions-fork",
"path": "redis_sessions_fork/utils.py",
"copies": "1",
"size": "1418",
"license": "bsd-3-clause",
"hash": -2217537386608763400,
"line_mean": 23.0338983051,
"line_max": 60,
"alpha_frac": 0.6142454161,
"autogenerated": false,
"ratio": 3.906336088154... |
from functools import wraps
unique_options = dict([
('ledger', ['ledger_hash', 'ledger_index']),
])
class RippleRPCError(Exception):
""""
An error in an RPC response.
"""
def __init__(self, name, code, message):
self.name = name
self.code = code
self.message = message
... | {
"repo_name": "thelinuxkid/ripple",
"path": "ripple/jsonrpc.py",
"copies": "1",
"size": "3095",
"license": "mit",
"hash": -3510120293464666000,
"line_mean": 29.0485436893,
"line_max": 71,
"alpha_frac": 0.4584814216,
"autogenerated": false,
"ratio": 4.881703470031546,
"config_test": false,
"ha... |
from functools import wraps
"""
wraps helps to remember information about wrapped function,
for example attributes like __name__, __doc__
details: http://docs.python.org/2/library/functools.html#functools.wraps
"""
def instance_cache(func):
"""
Stores returned value as instance attr.
Currently function ar... | {
"repo_name": "st4lk/django-relish",
"path": "relish/decorators/generic.py",
"copies": "1",
"size": "2665",
"license": "bsd-3-clause",
"hash": 5485489625308807000,
"line_mean": 27.9673913043,
"line_max": 74,
"alpha_frac": 0.6037523452,
"autogenerated": false,
"ratio": 4.449081803005009,
"config... |
from functools import wraps
try:
from decorator.src.decorator import decorator
except:
from decorator import decorator
class NotFoundException(Exception):
def __init__(self, response):
try:
self.data = response.json()
if 'errors' in self.data:
msg = self.data['... | {
"repo_name": "robinson96/GRAPE",
"path": "stashy/stashy/errors.py",
"copies": "1",
"size": "1853",
"license": "bsd-3-clause",
"hash": 3291324731120601000,
"line_mean": 26.6567164179,
"line_max": 70,
"alpha_frac": 0.58283864,
"autogenerated": false,
"ratio": 4.299303944315545,
"config_test": fa... |
from functools import wraps
try:
from io import BytesIO
except ImportError: # pragma: no cover
from cStringIO import StringIO as BytesIO
from flask import Blueprint, abort, g, request
from werkzeug.exceptions import InternalServerError
from celery import states
from . import celery
from .utils import url_fo... | {
"repo_name": "send2zhao/boilerplate",
"path": "flack/tasks.py",
"copies": "1",
"size": "3386",
"license": "mit",
"hash": 3448926707813755000,
"line_mean": 34.6421052632,
"line_max": 78,
"alpha_frac": 0.6408741878,
"autogenerated": false,
"ratio": 4.0893719806763285,
"config_test": false,
"ha... |
from functools import wraps, partial
from again.utils import unique_hex
from ..utils.stats import Stats, Aggregator
from ..exceptions import VykedServiceException
from ..utils.common_utils import json_file_to_dict, valid_timeout
import asyncio
import logging
import socket
import setproctitle
import time
import tracebac... | {
"repo_name": "amanwriter/vyked",
"path": "vyked/decorators/tcp.py",
"copies": "1",
"size": "8739",
"license": "mit",
"hash": 8091175935342554000,
"line_mean": 35.2614107884,
"line_max": 120,
"alpha_frac": 0.6092230232,
"autogenerated": false,
"ratio": 4.15351711026616,
"config_test": false,
... |
from functools import wraps, partial
from again.utils import unique_hex
from ..utils.stats import Stats, Aggregator
from ..exceptions import VykedServiceException
from ..utils.common_utils import valid_timeout, X_REQUEST_ID, get_uuid
import asyncio
import logging
import socket
import setproctitle
import time
import tra... | {
"repo_name": "1mgOfficial/vyked",
"path": "vyked/decorators/tcp.py",
"copies": "1",
"size": "9301",
"license": "mit",
"hash": -6005088078110196000,
"line_mean": 35.4745098039,
"line_max": 123,
"alpha_frac": 0.6084292012,
"autogenerated": false,
"ratio": 4.122783687943262,
"config_test": false,... |
from functools import wraps, partial
from django.core.validators import RegexValidator
from django.forms import Form, Field, CharField, TextInput, FileField
from collections import OrderedDict
from django.forms.formsets import formset_factory
class UploadStaticForm(Form):
file = FileField()
class FormFromPatter... | {
"repo_name": "maranathaaa/templado",
"path": "templado/forms.py",
"copies": "2",
"size": "2619",
"license": "bsd-2-clause",
"hash": 8019699657351266000,
"line_mean": 46.6363636364,
"line_max": 113,
"alpha_frac": 0.5547919053,
"autogenerated": false,
"ratio": 4.761818181818182,
"config_test": f... |
from functools import wraps, partial
from .helpers import FSMLogDescriptor
def fsm_log_by(func):
@wraps(func)
def wrapped(instance, *args, **kwargs):
try:
by = kwargs['by']
except KeyError:
return func(instance, *args, **kwargs)
with FSMLogDescriptor(instance, '... | {
"repo_name": "ticosax/django-fsm-log",
"path": "django_fsm_log/decorators.py",
"copies": "2",
"size": "1035",
"license": "mit",
"hash": 7035178754776893000,
"line_mean": 29.4411764706,
"line_max": 70,
"alpha_frac": 0.5971014493,
"autogenerated": false,
"ratio": 4.330543933054393,
"config_test"... |
from functools import wraps, partial
from inspect import getfullargspec
from typing import Callable, Union, Any, TypeVar, Tuple, Generic, cast
A = TypeVar('A')
B = TypeVar('B')
C = TypeVar('C')
def curried(func: Callable[..., B]) -> Callable[[A], Callable[..., Union[Callable, B]]]:
@wraps(func)
def _curried(... | {
"repo_name": "tek/amino",
"path": "amino/func.py",
"copies": "1",
"size": "2512",
"license": "mit",
"hash": -3417239705792789500,
"line_mean": 21.6306306306,
"line_max": 120,
"alpha_frac": 0.5290605096,
"autogenerated": false,
"ratio": 3.21227621483376,
"config_test": false,
"has_no_keywords... |
from functools import wraps, partial
from inspect import iscoroutine
from .loop import Loop, get_current_loop
from .timer import Timer
from .idle import Idle
from .workers import worker
from .stream import Stream
from . import fs
from . import net
from . import process
get_default_loop = Loop.get_default_loop
def s... | {
"repo_name": "srossross/uvio",
"path": "uvio/__init__.py",
"copies": "1",
"size": "2236",
"license": "mit",
"hash": 1386645413584365000,
"line_mean": 23.3043478261,
"line_max": 107,
"alpha_frac": 0.6176207513,
"autogenerated": false,
"ratio": 3.9575221238938054,
"config_test": false,
"has_no... |
from functools import wraps, partial
from itertools import product
import numpy as np
from sympy import S, finite_diff_weights, cacheit, sympify
from devito.tools import Tag, as_tuple
class Transpose(Tag):
"""
Utility class to change the sign of a derivative. This is only needed
for odd order derivative... | {
"repo_name": "opesci/devito",
"path": "devito/finite_differences/tools.py",
"copies": "1",
"size": "9364",
"license": "mit",
"hash": 4298944745306953700,
"line_mean": 32.3238434164,
"line_max": 88,
"alpha_frac": 0.5963263563,
"autogenerated": false,
"ratio": 3.5537001897533207,
"config_test": ... |
from functools import wraps, partial
from .methods import __methods__
from .errors import IpernityError
from .rest import call_api
def _required_params(info):
params = info.get('parameters', [])
requires = [p['name'] for p in
filter(lambda p: bool(p.get('required', 0)), params)]
# api_key ... | {
"repo_name": "oneyoung/python-ipernity-api",
"path": "ipernity_api/reflection.py",
"copies": "1",
"size": "6336",
"license": "apache-2.0",
"hash": 7087239991484043000,
"line_mean": 34.2,
"line_max": 78,
"alpha_frac": 0.5542929293,
"autogenerated": false,
"ratio": 4.258064516129032,
"config_tes... |
from functools import wraps, partial
from nose.tools import make_decorator as make_dec, istest
from wumpus.events import *
from wumpus.server import Server
from wumpus.client import Client
from wumpus.tests.mock import FakeServer, FakeClient
from wumpus.core import Player
from wumpus.network_node import Network_Node
... | {
"repo_name": "marky1991/Legend-of-Wumpus",
"path": "wumpus/tests/test_networking.py",
"copies": "1",
"size": "2809",
"license": "mit",
"hash": -6641253414738168000,
"line_mean": 38.5633802817,
"line_max": 113,
"alpha_frac": 0.6646493414,
"autogenerated": false,
"ratio": 3.7403462050599203,
"co... |
from functools import wraps, partial
from operator import add, sub, mul
from heapq import nlargest, nsmallest
from random import randint
import lark
def unpack(m, values):
return [values[i] if i < len(values) else None for i in range(m)]
class Modifier:
def __init__(self, values):
self.op, self.valu... | {
"repo_name": "micaiahparker/diediedie",
"path": "char.py",
"copies": "1",
"size": "1425",
"license": "mit",
"hash": 8818988497614289000,
"line_mean": 25.9056603774,
"line_max": 92,
"alpha_frac": 0.6035087719,
"autogenerated": false,
"ratio": 3.1879194630872485,
"config_test": false,
"has_no_... |
from functools import wraps, partial
from types import FunctionType
from typing import Callable, Any, Dict
from classes import MshException, MultiDecorator, Function
from util import skip_spaces, keep_leading
class RegisterError(Exception):
pass
# Unbound methods.
parsers = {} # type: Dict[str, Function]
"... | {
"repo_name": "jimbo1qaz/msh",
"path": "utils/decorators.py",
"copies": "1",
"size": "5832",
"license": "mit",
"hash": -6142436296086617000,
"line_mean": 24.8053097345,
"line_max": 102,
"alpha_frac": 0.6193415638,
"autogenerated": false,
"ratio": 3.814257684761282,
"config_test": false,
"has_... |
from functools import wraps, partial
from ...utils.logging import logger
from ...constants import LOG_URL_MAX_LENGTH
def logging_dispatch_middleware(reporter, dispatch):
@wraps(dispatch)
async def enhanced(*args, **kwargs):
log = _log_factory(reporter)
log('Dispatching reporter with {} intel'.... | {
"repo_name": "kuc2477/news",
"path": "news/contrib/logging/middlewares.py",
"copies": "1",
"size": "1312",
"license": "mit",
"hash": -768308979139703000,
"line_mean": 30.2380952381,
"line_max": 75,
"alpha_frac": 0.6356707317,
"autogenerated": false,
"ratio": 3.9047619047619047,
"config_test": ... |
from functools import wraps, partial
import inspect
from json import JSONEncoder
from threading import local as threadlocal
from typing import AnyStr, Tuple, Optional
import warnings
import copy
import logging
from datetime import datetime, timedelta
from urllib.parse import urlparse, urlunsplit
MAX_PAYLOAD_LENGTH = 1... | {
"repo_name": "bugsnag/bugsnag-python",
"path": "bugsnag/utils.py",
"copies": "1",
"size": "12587",
"license": "mit",
"hash": -3181755011718781400,
"line_mean": 30.8658227848,
"line_max": 79,
"alpha_frac": 0.5884642886,
"autogenerated": false,
"ratio": 4.223825503355704,
"config_test": false,
... |
from functools import wraps, partial
import logging
def attach_wrapper(obj, func=None):
if func is None:
return partial(attach_wrapper, obj)
setattr(obj, func.__name__, func)
return func
def logged(level, name=None, message=None):
'''
Add logging to a function. level is the logging
le... | {
"repo_name": "hyller/CodeLibrary",
"path": "python-cookbook-master/src/9/defining_a_decorator_with_user_adjustable_attributes/example1.py",
"copies": "2",
"size": "2176",
"license": "unlicense",
"hash": 6561465850107215000,
"line_mean": 21.9052631579,
"line_max": 55,
"alpha_frac": 0.6125919118,
"a... |
from functools import wraps, partial
import logging
"""
topic: 写一个装饰器来包装一个函数,并且允许用户提供参数在运行时控制装饰器行为。
desc: 引入一个访问函数,使用 nonlocal 来修改内部变量。 然后这个访问函数被作为一个属性赋值给包装函数。
"""
def attach_wrapper(obj, func=None):
if func is None:
return partial(attach_wrapper, obj)
setattr(obj, func.__name__, func)
return ... | {
"repo_name": "AtlantisFox/Green-Point-Challenge",
"path": "python_cookbook/c09/p05_adjust_attribute.py",
"copies": "1",
"size": "1551",
"license": "mit",
"hash": 2993371002009348600,
"line_mean": 20.4615384615,
"line_max": 61,
"alpha_frac": 0.6114695341,
"autogenerated": false,
"ratio": 2.961783... |
from functools import wraps, partial
import numpy as np
from menpo.shape import PointCloud
def pointcloud_to_points(wrapped):
@wraps(wrapped)
def wrapper(*args, **kwargs):
args = list(args)
for index, arg in enumerate(args):
if isinstance(arg, PointCloud):
args[ind... | {
"repo_name": "grigorisg9gr/menpofit",
"path": "menpofit/error/base.py",
"copies": "6",
"size": "20913",
"license": "bsd-3-clause",
"hash": 6466178541834077000,
"line_mean": 33.7392026578,
"line_max": 103,
"alpha_frac": 0.5745708411,
"autogenerated": false,
"ratio": 3.5718189581554225,
"config_... |
from functools import wraps, partial
import re
from itertools import chain, repeat
class NoMatch(Exception):
pass
class Any(object):
def __init__(self, *allowed_types, _matcher=None, _repeat=False):
self._allowed_types = allowed_types
if _matcher is None:
self.matcher = lambda ar... | {
"repo_name": "Luftzig/pypatterns",
"path": "pypatterns/patterns.py",
"copies": "1",
"size": "3428",
"license": "mit",
"hash": 4459346455901170000,
"line_mean": 28.2991452991,
"line_max": 120,
"alpha_frac": 0.5889731622,
"autogenerated": false,
"ratio": 3.882219705549264,
"config_test": false,
... |
from functools import wraps, partial
import six
from django.http import HttpRequest
from django.views.generic import View
try:
from rest_framework.request import Request as RestRequest
from rest_framework.views import APIView
except ImportError:
"""
Fake class for rest_framework
"""
class Rest... | {
"repo_name": "romain-li/django-validator",
"path": "django_validator/decorators.py",
"copies": "1",
"size": "5695",
"license": "mit",
"hash": -4200912720367004700,
"line_mean": 34.59375,
"line_max": 114,
"alpha_frac": 0.6087796313,
"autogenerated": false,
"ratio": 4.353975535168196,
"config_te... |
from functools import wraps, partial
import warnings
from .list_ import iterate_items
__all__ = [
'memoized', 'memoized_property', 'memoized_method',
'assert_hashable', 'deprecated',
]
def assert_hashable(*args, **kw):
""" Verify that each argument is hashable.
Passes silently if successful. Raise... | {
"repo_name": "shazow/unstdlib.py",
"path": "unstdlib/standard/functools_.py",
"copies": "1",
"size": "7235",
"license": "mit",
"hash": -6111854586342349000,
"line_mean": 29.3991596639,
"line_max": 88,
"alpha_frac": 0.5695922598,
"autogenerated": false,
"ratio": 4.064606741573034,
"config_test"... |
from functools import wraps, partial
import warnings
Version, version, __version__, VERSION = ('0.9.2',) * 4
JSON_HEADERS = {
'Content-type': 'application/json',
'Accept': 'application/json',
'client-lib': 'python',
'version-number': VERSION
}
from indicoio.text.twitter_engagement import twitter_enga... | {
"repo_name": "wassname/IndicoIo-python",
"path": "indicoio/__init__.py",
"copies": "1",
"size": "1775",
"license": "mit",
"hash": 2599833600839904000,
"line_mean": 33.8039215686,
"line_max": 139,
"alpha_frac": 0.7138028169,
"autogenerated": false,
"ratio": 3.6298568507157465,
"config_test": fa... |
from functools import wraps, partial
import warnings
Version, version, __version__, VERSION = ('0.9.3',) * 4
JSON_HEADERS = {
'Content-type': 'application/json',
'Accept': 'application/json',
'client-lib': 'python',
'version-number': VERSION
}
from indicoio.text.twitter_engagement import twitter_enga... | {
"repo_name": "madisonmay/IndicoIo-python",
"path": "indicoio/__init__.py",
"copies": "2",
"size": "1797",
"license": "mit",
"hash": -589688423046982700,
"line_mean": 34.2352941176,
"line_max": 139,
"alpha_frac": 0.7156371731,
"autogenerated": false,
"ratio": 3.6303030303030304,
"config_test": ... |
from functools import wraps, partial
class _CtxImpl:
def __init__(self):
self._has_buffered = set()
class _Context:
def __init__(self):
self._impl = _CtxImpl()
self._parsed = False
self._checked = False
self._slot_policy = None
self._slot_expr = []
... | {
"repo_name": "jdfekete/progressivis",
"path": "progressivis/core/decorators.py",
"copies": "1",
"size": "6794",
"license": "bsd-2-clause",
"hash": 2029157158506172400,
"line_mean": 38.0459770115,
"line_max": 108,
"alpha_frac": 0.5419487783,
"autogenerated": false,
"ratio": 4.005896226415095,
"... |
from functools import wraps, partial
from seamus.exceptions import SeamusException
from seamus.seamus import Seamus
REFACTORED_FUNC = 'refactored_func'
FACTORY = 'factory'
DECORATOR_ARGS = [REFACTORED_FUNC, FACTORY]
def seamus(func=None, **dkwargs):
"""
Run seamus test with the supplied arguments
:retu... | {
"repo_name": "nerandell/seamus",
"path": "seamus/decorator.py",
"copies": "1",
"size": "1204",
"license": "mit",
"hash": -231959335567915330,
"line_mean": 30.6842105263,
"line_max": 102,
"alpha_frac": 0.6013289037,
"autogenerated": false,
"ratio": 3.7275541795665634,
"config_test": false,
"h... |
from functools import wraps
from django.shortcuts import redirect
from django.utils.decorators import method_decorator
from django.core.urlresolvers import reverse
from django.conf import settings
from datetime import datetime
from app.models import Users, Tokens, Providers, Consumers, Carers, ItExperience
f... | {
"repo_name": "silop4all/aod",
"path": "AssistanceOnDemand/app/decorators.py",
"copies": "1",
"size": "6399",
"license": "apache-2.0",
"hash": 5219670525684994000,
"line_mean": 48.0078125,
"line_max": 174,
"alpha_frac": 0.5302390999,
"autogenerated": false,
"ratio": 4.829433962264151,
"config_t... |
from functools import wraps
from flask import current_app, request, session, redirect
from werkzeug.local import LocalProxy
import requests
import urllib
__version__ = "1.0"
OLINAPPS_STR = 'http://olinapps.com/external?%s'
class OlinAuth(object):
def __init__(self, app=None, host_name=None):
... | {
"repo_name": "corydolphin/flask-olinauth",
"path": "flask_olinauth.py",
"copies": "1",
"size": "4205",
"license": "mit",
"hash": -1259385816238112300,
"line_mean": 31.373015873,
"line_max": 104,
"alpha_frac": 0.594530321,
"autogenerated": false,
"ratio": 4.159248269040554,
"config_test": false... |
from functools import wraps
from flask import Flask, make_response
def headers(headerDict={}, **headerskwargs):
'''
This function is the decorator which is used to wrap a Flask route with.
Either pass a dictionary of headers to be set as the headerDict keyword
argument, or pass header values as... | {
"repo_name": "corydolphin/flask-headers",
"path": "flask_headers.py",
"copies": "1",
"size": "1298",
"license": "mit",
"hash": 3102774932852997600,
"line_mean": 39.935483871,
"line_max": 81,
"alpha_frac": 0.6594761171,
"autogenerated": false,
"ratio": 4.669064748201439,
"config_test": false,
... |
from functools import wraps
from flask import redirect,url_for,abort,current_app,request
from flask.ext.security import current_user
from datetime import datetime,date, timedelta
import time
#Add http to the URL if not already there
def format_url(url):
if not url.startswith('http') or not url.startswith('... | {
"repo_name": "unifispot/unifispot-free",
"path": "bluespot/base/utils/helper.py",
"copies": "1",
"size": "3208",
"license": "mit",
"hash": 2597347342394282500,
"line_mean": 31.4375,
"line_max": 128,
"alpha_frac": 0.59819202,
"autogenerated": false,
"ratio": 3.641316685584563,
"config_test": fa... |
from functools import wraps
from flask import request, send_from_directory
import sqlite3
import hashlib
'''
Dirty auth implementation
'''
def auth_required(f):
@wraps(f)
def decorated(*args, **kwargs):
token = None
if 'auth-token' in request.cookies:
token = request.... | {
"repo_name": "Ambalavanar/ferry",
"path": "service/security/api_auth.py",
"copies": "1",
"size": "2244",
"license": "mit",
"hash": 3564546706010002400,
"line_mean": 31,
"line_max": 105,
"alpha_frac": 0.5369875223,
"autogenerated": false,
"ratio": 4.0359712230215825,
"config_test": false,
"ha... |
from functools import wraps
import importlib
def model_constructor(f):
""" Wraps the function 'f' which returns the network. An extra field 'constructor' is added to the network returned
by 'f'. This field contains an instance of the 'NetConstructor' class, which contains the information needed to
... | {
"repo_name": "PaddlePaddle/models",
"path": "PaddleCV/tracking/ltr/admin/model_constructor.py",
"copies": "1",
"size": "2104",
"license": "apache-2.0",
"hash": 4402343705075434500,
"line_mean": 41.8333333333,
"line_max": 119,
"alpha_frac": 0.644486692,
"autogenerated": false,
"ratio": 4.46709129... |
from functools import wraps
import inspect
import json
from flask import Response, current_app, request
__all__ = ('Refract', 'Prism', 'ResponseMapper')
class Refract(Response):
STATUS_OK = 200
DEFAULT_MIMETYPE = 'text/json'
PRISM_VERSION_ATTRIBUTE = 'prism_version'
PRISM_MIMETYPE_ATT... | {
"repo_name": "patrickmccallum/flask-prism",
"path": "flask_prism.py",
"copies": "1",
"size": "14043",
"license": "mit",
"hash": -6100292392391209000,
"line_mean": 35.6487935657,
"line_max": 119,
"alpha_frac": 0.5545111443,
"autogenerated": false,
"ratio": 4.503848620910841,
"config_test": fals... |
from functools import wraps
from django.http import HttpResponse
from django.template.context import RequestContext
from django.shortcuts import render_to_response
from django.utils import simplejson
def render_to(template=None, mimetype=None):
def renderer(function):
@wraps(function)
... | {
"repo_name": "dbreen/games",
"path": "games/utils/decorators.py",
"copies": "1",
"size": "1299",
"license": "mit",
"hash": -8569725297775521000,
"line_mean": 32.1842105263,
"line_max": 103,
"alpha_frac": 0.6351039261,
"autogenerated": false,
"ratio": 4.775735294117647,
"config_test": false,
... |
from functools import wraps
from django.middleware.cache import CacheMiddleware
from django.utils.cache import add_never_cache_headers, patch_cache_control
from django.utils.decorators import (
available_attrs, decorator_from_middleware_with_args,
)
def cache_page(*args, **kwargs):
"""
Decorat... | {
"repo_name": "diego-d5000/MisValesMd",
"path": "env/lib/python2.7/site-packages/django/views/decorators/cache.py",
"copies": "2",
"size": "2364",
"license": "mit",
"hash": 3903271864025219000,
"line_mean": 37.4,
"line_max": 94,
"alpha_frac": 0.679357022,
"autogenerated": false,
"ratio": 4.198934... |
from functools import wraps
from django.middleware.csrf import CsrfViewMiddleware, get_token
from django.utils.decorators import available_attrs, decorator_from_middleware
csrf_protect = decorator_from_middleware(CsrfViewMiddleware)
csrf_protect.__name__ = "csrf_protect"
csrf_protect.__doc__ = """
This decora... | {
"repo_name": "yephper/django",
"path": "django/views/decorators/csrf.py",
"copies": "2",
"size": "2262",
"license": "bsd-3-clause",
"hash": 4410747656402163700,
"line_mean": 35.7,
"line_max": 111,
"alpha_frac": 0.7130857648,
"autogenerated": false,
"ratio": 3.940766550522648,
"config_test": fa... |
from functools import wraps
from django.utils.decorators import available_attrs
def xframe_options_deny(view_func):
"""
Modifies a view function so its response has the X-Frame-Options HTTP
header set to 'DENY' as long as the response doesn't already have that
header set.
e.g.
... | {
"repo_name": "yephper/django",
"path": "django/views/decorators/clickjacking.py",
"copies": "1",
"size": "1805",
"license": "bsd-3-clause",
"hash": -8673396118064572000,
"line_mean": 27.5901639344,
"line_max": 78,
"alpha_frac": 0.6227146814,
"autogenerated": false,
"ratio": 3.8650963597430406,
... |
from functools import wraps
from flask import abort
from flask import has_request_context
from flask import request
from flask_restful import fields
from flask_restful import marshal
from flask_restful import marshal_with
from flask_restful.utils import unpack
from flask_sqlalchemy import BaseQuery
from flas... | {
"repo_name": "by46/coffee",
"path": "flask_kits1/restful/pagination.py",
"copies": "1",
"size": "4683",
"license": "mit",
"hash": -5970442448781456000,
"line_mean": 30.0753424658,
"line_max": 97,
"alpha_frac": 0.5673713432,
"autogenerated": false,
"ratio": 4.364398881640261,
"config_test": fal... |
from functools import wraps
from flask import abort
from flask import redirect
from flask import request
from flask import url_for
from flask_login import current_user
from furl import furl
def permission_required(permission):
def decorator(f):
@wraps(f)
def decorated_function(*args,... | {
"repo_name": "by46/flask-kits",
"path": "flask_kits/decorators/permission.py",
"copies": "1",
"size": "2270",
"license": "mit",
"hash": -9020362648406861000,
"line_mean": 23.2222222222,
"line_max": 67,
"alpha_frac": 0.5938325991,
"autogenerated": false,
"ratio": 4.274952919020715,
"config_test... |
from functools import wraps
from google.appengine.ext import db
from google.appengine.api import users
from db_helper import IdUrlField, generate_sorted_query, update_model
from flask import abort, redirect, request
from flask.ext.restful import Resource, reqparse, fields, marshal
from auth import requires_au... | {
"repo_name": "pwojt/beer_app_414",
"path": "user_api.py",
"copies": "1",
"size": "3831",
"license": "apache-2.0",
"hash": -8069848243445657000,
"line_mean": 31.6052631579,
"line_max": 104,
"alpha_frac": 0.6042808666,
"autogenerated": false,
"ratio": 3.694310511089682,
"config_test": false,
"... |
from functools import wraps
class Log:
"""
Класс декоратор для логирования функций
"""
def __init__(self, logger):
# запоминаем логгер, чтобы можно было использовать разные
self.logger = logger
@staticmethod
def _create_message(result=None, *args, **kwargs):
... | {
"repo_name": "OOPSA45/Python-learn-",
"path": "my_package/log/decorators.py",
"copies": "1",
"size": "2217",
"license": "apache-2.0",
"hash": 7405134841538525000,
"line_mean": 31.9607843137,
"line_max": 102,
"alpha_frac": 0.5595375723,
"autogenerated": false,
"ratio": 2.3569482288828336,
"conf... |
from functools import wraps
from django.middleware.cache import CacheMiddleware
from django.utils.cache import add_never_cache_headers, patch_cache_control
from django.utils.decorators import (
available_attrs, decorator_from_middleware_with_args,
)
def cache_page(*args, **kwargs):
"""
Decorator for view... | {
"repo_name": "letouriste001/SmartForest_2.0",
"path": "python3.4Smartforest/lib/python3.4/site-packages/django/views/decorators/cache.py",
"copies": "1",
"size": "2304",
"license": "mit",
"hash": -5729212962489686000,
"line_mean": 37.4,
"line_max": 94,
"alpha_frac": 0.6970486111,
"autogenerated": ... |
from functools import wraps
from django.middleware.csrf import CsrfViewMiddleware, get_token
from django.utils.decorators import available_attrs, decorator_from_middleware
csrf_protect = decorator_from_middleware(CsrfViewMiddleware)
csrf_protect.__name__ = "csrf_protect"
csrf_protect.__doc__ = """
This decorator adds... | {
"repo_name": "letouriste001/SmartForest_2.0",
"path": "python3.4Smartforest/lib/python3.4/site-packages/django/views/decorators/csrf.py",
"copies": "1",
"size": "2202",
"license": "mit",
"hash": 346350312581909600,
"line_mean": 35.7,
"line_max": 111,
"alpha_frac": 0.7325158946,
"autogenerated": fa... |
from functools import wraps
from django.utils.decorators import available_attrs
def xframe_options_deny(view_func):
"""
Modifies a view function so its response has the X-Frame-Options HTTP
header set to 'DENY' as long as the response doesn't already have that
header set.
e.g.
@xframe_optio... | {
"repo_name": "letouriste001/SmartForest_2.0",
"path": "python3.4Smartforest/lib/python3.4/site-packages/django/views/decorators/clickjacking.py",
"copies": "1",
"size": "1744",
"license": "mit",
"hash": -2041274687794030600,
"line_mean": 27.5901639344,
"line_max": 78,
"alpha_frac": 0.6444954128,
"... |
from functools import wraps, update_wrapper
from flask import Flask, render_template, request, Response, jsonify, make_response
#----------------------------------------------
# decorator for turning off browser caching
#----------------------------------------------
def nocache(f):
"""Stop caching for pages wrap... | {
"repo_name": "johnmcdonnell/psiTurk",
"path": "psiturk/user_utils.py",
"copies": "1",
"size": "1930",
"license": "mit",
"hash": -7014919257699078000,
"line_mean": 36.1346153846,
"line_max": 83,
"alpha_frac": 0.5740932642,
"autogenerated": false,
"ratio": 4.7073170731707314,
"config_test": fals... |
from functools import wraps,update_wrapper
from datetime import timedelta
from flask import request,make_response,abort,current_app
from models import Survey,User,Response
import pymongo
import settings
from settings import logger
import uuid
import urlparse
from werkzeug.routing import BaseConverter
class RegexConve... | {
"repo_name": "adewes/instant-feedback",
"path": "get_feedback/utils.py",
"copies": "1",
"size": "7436",
"license": "mit",
"hash": -804023756826648600,
"line_mean": 32.3452914798,
"line_max": 167,
"alpha_frac": 0.5687197418,
"autogenerated": false,
"ratio": 4.366412213740458,
"config_test": fal... |
from functools import wraps, update_wrapper
# You can't trivially replace this `functools.partial` because this binds to
# classes and returns bound instances, whereas functools.partial (on CPython)
# is a type and its instances don't bind.
def curry(_curried_func, *args, **kwargs):
def _curried(*moreargs, **more... | {
"repo_name": "skevy/django",
"path": "django/utils/functional.py",
"copies": "2",
"size": "9520",
"license": "bsd-3-clause",
"hash": 8645507386163942000,
"line_mean": 34.9245283019,
"line_max": 130,
"alpha_frac": 0.5698529412,
"autogenerated": false,
"ratio": 4.488448844884489,
"config_test": ... |
from functools import wraps, WRAPPER_ASSIGNMENTS
from django.http.response import HttpResponse
from rest_framework_extensions.settings import extensions_api_settings
def get_cache(alias):
from django.core.cache import caches
return caches[alias]
class CacheResponse:
"""
Store/Receive and return c... | {
"repo_name": "chibisov/drf-extensions",
"path": "rest_framework_extensions/cache/decorators.py",
"copies": "1",
"size": "4464",
"license": "mit",
"hash": -3111288558497384000,
"line_mean": 32.3134328358,
"line_max": 90,
"alpha_frac": 0.5488351254,
"autogenerated": false,
"ratio": 4.7641408751334... |
from FunctorApplicativeMonad import Functor, Applicative, Monad
from abc import ABCMeta, abstractmethod
from ParseResult import *
from Utils import *
class Parser(Functor, Applicative, Monad):
"""A monadic parser, similar to Haskell's Parsec. In contrast to Parsec,
this parser backtracks by default: this beha... | {
"repo_name": "oisdk/PyParse",
"path": "Parser.py",
"copies": "1",
"size": "4717",
"license": "mit",
"hash": -8202000146180460000,
"line_mean": 29.6298701299,
"line_max": 85,
"alpha_frac": 0.5743057028,
"autogenerated": false,
"ratio": 3.383787661406026,
"config_test": false,
"has_no_keywords... |
from FunctorApplicativeMonad import Functor, Applicative, Monad
from typing import Callable, Any
from functools import partial
class Maybe(Functor, Applicative, Monad):
def __init__(self, value):
self._is_just = True
self._value = value
def fmap(self, mapper: Callable[[Any], Any]) -> 'Maybe':... | {
"repo_name": "oisdk/PyParse",
"path": "Maybe.py",
"copies": "1",
"size": "1471",
"license": "mit",
"hash": 7412349542677714000,
"line_mean": 27.8431372549,
"line_max": 82,
"alpha_frac": 0.5730795377,
"autogenerated": false,
"ratio": 3.9122340425531914,
"config_test": false,
"has_no_keywords"... |
from FunctorApplicativeMonad import Functor, Applicative, Monad
from typing import Callable, Any, TypeVar, Tuple, Generic, cast, Union
from abc import ABCMeta, abstractmethod
A = TypeVar('A')
B = TypeVar('B')
C = TypeVar('C')
S = TypeVar('S')
class State(Functor, Applicative, Monad, Generic[S,A]):
def __init__(s... | {
"repo_name": "oisdk/PyParse",
"path": "State.py",
"copies": "1",
"size": "1182",
"license": "mit",
"hash": 3867814527406225000,
"line_mean": 26.488372093,
"line_max": 70,
"alpha_frac": 0.5727580372,
"autogenerated": false,
"ratio": 3.2472527472527473,
"config_test": false,
"has_no_keywords":... |
from funcy import compose, partial, walk, mapcat, first,\
str_join
from firestone import get_user, get_f, merge_id
from django.core.urlresolvers import reverse
import date_converter
w_ids = partial(walk, lambda (k, v): merge_id(k, v))
as_arr = partial(lambda v: v.values())
mids = compose(as_arr, w_ids)
p_collect... | {
"repo_name": "popara/jonny-api",
"path": "matching/models.py",
"copies": "1",
"size": "4572",
"license": "mit",
"hash": -7200669232063566000,
"line_mean": 21.9748743719,
"line_max": 81,
"alpha_frac": 0.5839895013,
"autogenerated": false,
"ratio": 3.1038696537678208,
"config_test": false,
"ha... |
from funcy import ContextDecorator
from django.db.models import Manager
from django.db.models.query import QuerySet
# query
def cached_as(*samples, **kwargs):
return lambda func: func
cached_view_as = cached_as
def install_cacheops():
if not hasattr(Manager, 'get_queryset'):
Manager.get_queryset = la... | {
"repo_name": "andwun/django-cacheops",
"path": "cacheops/fake.py",
"copies": "2",
"size": "1465",
"license": "bsd-3-clause",
"hash": 631760818426064300,
"line_mean": 20.8656716418,
"line_max": 64,
"alpha_frac": 0.6887372014,
"autogenerated": false,
"ratio": 3.690176322418136,
"config_test": fa... |
from funcy import first
from pygtrie import Trie
from dvc.exceptions import OutputDuplicationError, OverlappingOutputPathsError
def build_outs_trie(stages):
outs = Trie()
for stage in stages:
for out in stage.outs:
out_key = out.path_info.parts
# Check for dup outs
... | {
"repo_name": "efiop/dvc",
"path": "dvc/repo/trie.py",
"copies": "1",
"size": "1445",
"license": "apache-2.0",
"hash": -3374930792752370000,
"line_mean": 33.4047619048,
"line_max": 78,
"alpha_frac": 0.5287197232,
"autogenerated": false,
"ratio": 4.631410256410256,
"config_test": false,
"has_n... |
from funcy import group_by
from dvc.scm.tree import WorkingTree
def brancher( # noqa: E302
self, revs=None, all_branches=False, all_tags=False, all_commits=False
):
"""Generator that iterates over specified revisions.
Args:
revs (list): a list of revisions to iterate over.
all_branches ... | {
"repo_name": "dmpetrov/dataversioncontrol",
"path": "dvc/repo/brancher.py",
"copies": "1",
"size": "1420",
"license": "apache-2.0",
"hash": 6698374027437437000,
"line_mean": 27.4,
"line_max": 77,
"alpha_frac": 0.6014084507,
"autogenerated": false,
"ratio": 3.9664804469273744,
"config_test": fa... |
from funcy import group_by
def brancher( # noqa: E302
self,
revs=None,
all_branches=False,
all_tags=False,
all_commits=False,
all_experiments=False,
sha_only=False,
):
"""Generator that iterates over specified revisions.
Args:
revs (list): a list of revisions to iterate o... | {
"repo_name": "efiop/dvc",
"path": "dvc/repo/brancher.py",
"copies": "1",
"size": "2050",
"license": "apache-2.0",
"hash": -2657371672896400400,
"line_mean": 27.8732394366,
"line_max": 77,
"alpha_frac": 0.5780487805,
"autogenerated": false,
"ratio": 4.051383399209486,
"config_test": false,
"h... |
from funcy import identity
from jinja2 import Markup
from dxr.filters import QualifiedNameFilterBase, Filter, negatable
class _QualifiedNameFilter(QualifiedNameFilterBase):
lang = "rust"
class FunctionFilter(_QualifiedNameFilter):
name = 'function'
is_identifier = True
description = Markup('Function o... | {
"repo_name": "gartung/dxr",
"path": "dxr/plugins/rust/filters.py",
"copies": "1",
"size": "2424",
"license": "mit",
"hash": 3471569374878914000,
"line_mean": 26.2359550562,
"line_max": 84,
"alpha_frac": 0.720709571,
"autogenerated": false,
"ratio": 4.060301507537688,
"config_test": false,
"h... |
from funcy import *
import requests
from django.conf import settings
"""
TODO:
- threads to reduce processing time
- permissive include directive syntax support (virtual vs file, spaces everywhere)
- timeouts
- error handling
"""
class SsiMiddleware(object):
"""
Response-phase middleware that processes S... | {
"repo_name": "furagu/django-ssi",
"path": "middleware.py",
"copies": "1",
"size": "1427",
"license": "mit",
"hash": 869036808728355800,
"line_mean": 36.5526315789,
"line_max": 103,
"alpha_frac": 0.6194814296,
"autogenerated": false,
"ratio": 4.124277456647399,
"config_test": false,
"has_no_k... |
from funcy import project
from flask import render_template, url_for
from flask_login import login_required
from flask_restful import abort
from redash import models, settings
from redash.wsgi import app
from redash.utils import json_dumps
from redash.handlers import org_scoped_rule
from redash.authentication.org_reso... | {
"repo_name": "olivetree123/redash-x",
"path": "redash/handlers/embed.py",
"copies": "1",
"size": "1911",
"license": "bsd-2-clause",
"hash": -812700462589554300,
"line_mean": 38,
"line_max": 122,
"alpha_frac": 0.6248037677,
"autogenerated": false,
"ratio": 3.732421875,
"config_test": false,
"... |
from funcy import project
from flask import url_for
from flask_login import current_user
from mock import patch
from redash import models, settings
from tests import BaseTestCase
from tests import authenticated_user
class AuthenticationTestMixin(object):
def test_returns_404_when_not_unauthenticated(self):
... | {
"repo_name": "luozhanxin/redash-docker",
"path": "tests/test_handlers.py",
"copies": "7",
"size": "14778",
"license": "bsd-2-clause",
"hash": -7152801648980840000,
"line_mean": 36.6030534351,
"line_max": 121,
"alpha_frac": 0.6067803492,
"autogenerated": false,
"ratio": 3.78437900128041,
"confi... |
from Fund import Fund
from TAA import TAA
fundListPath = input( "Enter path to fundlist: " )
with open( fundListPath, 'r' ) as handle:
fundList = []
print( "Fetching data", end='', flush=True )
for line in handle:
if line == '\n' or line.startswith( '#' ):
continue
parts = lin... | {
"repo_name": "Swassie/FundInfo-Python",
"path": "main.py",
"copies": "1",
"size": "1116",
"license": "mit",
"hash": 5562403688211334000,
"line_mean": 24.3636363636,
"line_max": 90,
"alpha_frac": 0.5869175627,
"autogenerated": false,
"ratio": 3.032608695652174,
"config_test": false,
"has_no_k... |
from funfactory.settings_base import *
from funfactory.manage import path
LESS_PREPROCESS = True
LESS_BIN = '/usr/local/bin/lessc'
COFFEE_PREPROCESS = True
COFFEE_BIN = 'coffee'
MEDIA_ROOT = path('m')
STATIC_ROOT = path('s')
STATIC_URL = '/static/'
STATICFILES_DIRS = (
path('static'),
)
# For integration wit... | {
"repo_name": "softak/webfaction_demo",
"path": "settings.py",
"copies": "1",
"size": "7846",
"license": "bsd-3-clause",
"hash": 892264076341193000,
"line_mean": 26.1487889273,
"line_max": 124,
"alpha_frac": 0.6145806781,
"autogenerated": false,
"ratio": 3.2814721873693014,
"config_test": false... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.