mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-18 04:02:35 +03:00
Make Flake8 happy
This commit is contained in:
parent
78a82c53d8
commit
ce0fe7a7c6
|
@ -56,7 +56,7 @@ class SimpleRateThrottle(BaseThrottle):
|
||||||
class. The attribute is a string of the form 'number_of_requests/period'.
|
class. The attribute is a string of the form 'number_of_requests/period'.
|
||||||
|
|
||||||
Period should be one of: ('s', 'sec', 'm', 'min', 'h', 'hour', 'd', 'day')
|
Period should be one of: ('s', 'sec', 'm', 'min', 'h', 'hour', 'd', 'day')
|
||||||
You may prefix period with a number. For example '1/30s' would be one
|
You may prefix period with a number. For example '1/30s' would be one
|
||||||
request every 30 seconds.
|
request every 30 seconds.
|
||||||
|
|
||||||
Previous request information used for throttling is stored in the cache.
|
Previous request information used for throttling is stored in the cache.
|
||||||
|
@ -106,7 +106,7 @@ class SimpleRateThrottle(BaseThrottle):
|
||||||
num, period = rate.split('/')
|
num, period = rate.split('/')
|
||||||
num_requests = int(num)
|
num_requests = int(num)
|
||||||
denominator_num = period[:-1]
|
denominator_num = period[:-1]
|
||||||
denominator_num = int(denominator_num) if len(denominator_num)>0 else 1
|
denominator_num = int(denominator_num) if len(denominator_num) > 0 else 1
|
||||||
duration = {'s': 1, 'm': 60, 'h': 3600, 'd': 86400}[period[-1]]
|
duration = {'s': 1, 'm': 60, 'h': 3600, 'd': 86400}[period[-1]]
|
||||||
duration *= denominator_num
|
duration *= denominator_num
|
||||||
return (num_requests, duration)
|
return (num_requests, duration)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user