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))