Skip to content
This repository has been archived by the owner on Mar 1, 2018. It is now read-only.

Commit

Permalink
Range does not take keyword arguments
Browse files Browse the repository at this point in the history
Signed-off-by: Laura <l@veriny.tf>
  • Loading branch information
Fuyukai committed Jul 4, 2017
1 parent d3b1ca1 commit 0164855
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
13 changes: 9 additions & 4 deletions kyoukai/blueprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ def _inner(func):

return _inner

def errorhandler(self, code: int):
def errorhandler(self, code: int, endcode: int = None, step: int = None):
"""
Helper decorator for adding an error handler.
Expand All @@ -257,10 +257,15 @@ def errorhandler(self, code: int):
route = bp.add_errorhandler(cbl, code)
:param code: The error handler code to use.
:param endcode: The end of the error code range to handle. Error handlers will be added \
for all requests between code and endcode. If this is not provided, only one code \
will be handled.
:param step: The step for the error handler range.
"""

def _inner(cbl):
self.add_errorhandler(cbl, code)
self.add_errorhandler(cbl, code, endcode, step)
return cbl

return _inner
Expand All @@ -286,7 +291,7 @@ def add_errorhandler(self, cbl, startcode: int, endcode: int = None, step: int =
:param cbl: The callable error handler.
:param startcode: The error code to handle, for example 404.
This also represents the start of an error range, if endcode is not None.
:param endcode: The end of the error code range to handle. Error handlers will be added
:param endcode: The end of the error code range to handle. Error handlers will be added \
for all requests between startcode and endcode.
:param step: The step for the error handler range.
"""
Expand All @@ -300,7 +305,7 @@ def add_errorhandler(self, cbl, startcode: int, endcode: int = None, step: int =
self.errorhandlers[startcode] = rtt
else:
# add a range of routes instead
for i in range(startcode, endcode, step=step or 1):
for i in range(startcode, endcode, step or 1):
self.errorhandlers[i] = rtt

rtt.bp = self
Expand Down
2 changes: 1 addition & 1 deletion kyoukai/routegroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def inner(func):
if endcode is None:
codes = [startcode]
else:
codes = range(startcode, endcode, step=step or 1)
codes = range(startcode, endcode, step or 1)

for code in codes:
try:
Expand Down

0 comments on commit 0164855

Please sign in to comment.