From f3d63966b944735d2926b0a2d5bd54aff90c1e20 Mon Sep 17 00:00:00 2001 From: Nils Dagsson Moskopp Date: Sat, 28 Sep 2019 14:03:20 +0200 Subject: * refactor dofiles in python --- dofile-in-python/all.do | 7 +++++-- dofile-in-python/target.do | 6 +++++- 2 files changed, 10 insertions(+), 3 deletions(-) (limited to 'dofile-in-python') diff --git a/dofile-in-python/all.do b/dofile-in-python/all.do index f236774..fb14f11 100644 --- a/dofile-in-python/all.do +++ b/dofile-in-python/all.do @@ -2,10 +2,13 @@ from subprocess import run from time import sleep +def redo_ifchange(dependency): + run(['redo-ifchange', dependency]) + with open('source', 'w') as f: f.write('foo') -run(['redo-ifchange', 'target']) +redo_ifchange('target') with open('target', 'r') as f: target_contents_1 = f.read() @@ -15,7 +18,7 @@ sleep(1) with open('source', 'w') as f: f.write('bar') -run(['redo-ifchange', 'target']) +redo_ifchange('target') with open('target', 'r') as f: target_contents_2 = f.read() diff --git a/dofile-in-python/target.do b/dofile-in-python/target.do index 5f0fadb..6897f80 100644 --- a/dofile-in-python/target.do +++ b/dofile-in-python/target.do @@ -2,5 +2,9 @@ from subprocess import run from datetime import datetime -run(['redo-ifchange', 'source']) +def redo_ifchange(dependency): + run(['redo-ifchange', dependency]) + +redo_ifchange('source') + print(datetime.now().timestamp()) -- cgit v1.2.3