def check_payed decorated Check only payed services def wrapper data i

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
def check_payed(decorated):
"""
Check only payed services
"""
def wrapper(data):
if data['payed']:
return decorated(data)
wrapper.__name__ = decorated.__name__
return wrapper
@check_payed
def some_check(data):
# ... some checks
pass
CHECKS = (
some_check,
)
def check_outgoing_data(records_iterator)
for record in records_iterator:
for check in CHECKS:
try:
check(record)
except ValueError, e:
logging.error("Fail to run %s at %d record: %s" %
(check.__name__, i, e))