| 1 |
def task(*fn, **kwargs): |
| 2 |
|
| 3 |
if fn: |
| 4 |
function = fn[0] |
| 5 |
function.task_metadata = {} |
| 6 |
return function |
| 7 |
|
| 8 |
|
| 9 |
def wrap(function): |
| 10 |
function.task_metadata = kwargs |
| 11 |
return function |
| 12 |
return wrap |
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
@task |
| 17 |
def simple(): |
| 18 |
print("thats all folks") |
| 19 |
|
| 20 |
@task(output=['my_input.txt']) |
| 21 |
def pre(to_create): |
| 22 |
with open(to_create[0], 'w') as fp: |
| 23 |
fp.write('foo') |
| 24 |
|
| 25 |
@task(output=['out1.txt', 'out2.txt']) |
| 26 |
def create(to_be_created): |
| 27 |
print("I should create these files: %s" % " ".join(to_be_created)) |
| 28 |
|
| 29 |
@task(input=['my_input.txt'], output=['my_output_result.txt']) |
| 30 |
def process(in_, out_): |
| 31 |
print("processing %s" % in_[0]) |
| 32 |
print("creating %s" % out_[0]) |
| 33 |
|
| 34 |
|
| 35 |
|