Skip to content

Commit

Permalink
Refactored decorators #4
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuszrezler committed Dec 10, 2020
1 parent c389313 commit 3f61ab4
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions checkmyxl/predefined.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
RED = (255, 0, 0)


def iterate(func):
def wrapper(sheet_range, *args):
def iterate(function):
def wrapper(sheet_range, *args, **kwargs):
for cell in sheet_range:
func(cell, *args)
function(cell, *args, **kwargs)
return wrapper


def highlight(func):
def wrapper(cell, *args):
if func(cell, *args):
cell.color = GREEN
else:
cell.color = RED
def highlight(function):
def wrapper(cell, *args, correct_color=GREEN, incorrect_color=RED,
**kwargs):
result = function(cell, *args, **kwargs)
cell.color = (incorrect_color, correct_color)[int(result)]
return result
return wrapper


Expand Down

0 comments on commit 3f61ab4

Please sign in to comment.