Conditions | 2 |
Total Lines | 16 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import functools |
||
30 | def hit_count(f): |
||
31 | @functools.wraps(f) |
||
1 ignored issue
–
show
|
|||
32 | def wrapped(*args, **kwargs): |
||
1 ignored issue
–
show
|
|||
33 | rv = f(*args, **kwargs) |
||
1 ignored issue
–
show
|
|||
34 | |||
35 | if current_app.config['TESTING']: |
||
1 ignored issue
–
show
|
|||
36 | from .rate_limit import FakeRedis |
||
1 ignored issue
–
show
|
|||
37 | redis = FakeRedis() |
||
1 ignored issue
–
show
|
|||
38 | else: # pragma: no cover |
||
1 ignored issue
–
show
|
|||
39 | from redis import Redis |
||
1 ignored issue
–
show
|
|||
40 | redis = Redis() |
||
1 ignored issue
–
show
|
|||
41 | |||
42 | key = 'hit-count%s' % (request.path) |
||
1 ignored issue
–
show
|
|||
43 | redis.incr(key) |
||
1 ignored issue
–
show
|
|||
44 | return rv |
||
1 ignored issue
–
show
|
|||
45 | return wrapped |
||
1 ignored issue
–
show
|
|||
46 | |||
170 |
The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:
If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.