Created
October 11, 2017 09:40
-
-
Save vlcinsky/fb33a5d9b0fa67c39a54de7d20d4789f to your computer and use it in GitHub Desktop.
Refactored dodo.py (see https://groups.google.com/d/msg/python-doit/aE6pwa7_uBU/cXBDFDQPAgAJ)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
def task_one(): | |
def create_cmd_string(a, b, target): | |
return "echo a: %s b: %s > %s" % (a, b, target) | |
with open("list_of_input_filenames.txt") as f: | |
fnames = [line.strip() for line in f.readlines() if line] | |
for a in fnames: | |
for b in fnames: | |
a_name_tail = os.path.basename(a).split("_")[1] | |
b_name_tail = os.path.basename(b).split("_")[1] | |
target = "output/output_%s_%s.out" % (a_name_tail, b_name_tail) | |
yield { | |
'name': "%s_%s" % (a_name_tail, b_name_tail), | |
'actions': [create_cmd_string(a, b, target)], | |
'file_dep': [a, b], | |
'targets': [target], | |
'clean': True | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
def task_1(): | |
def run_task1(a,b,targets): | |
os.system("programmename -i %s -o %s > %s"%(a,b,targets[0])) | |
return | |
LIST=open("list_of_input_filenames.txt",'r') | |
LIST=LIST.readlines() | |
for a in LIST: | |
a=a.rstrip() | |
for b in LIST: | |
b=b.rstrip() | |
if os.path.isfile("output/output_%s_%s.out"%(a.split("/")[-1].split("_")[1],b.split("/")[-1].split("_")[1])) == False: | |
yield {'name':"task1_%s_%s"%(a.split("/")[-1].split("_")[1],b.split("/")[-1].split("_")[1]), | |
'actions':[(run_task1,[a,b])], | |
'file_dep':[a,b], | |
'targets':["output/output_%s_%s.out"%(a.split("/")[-1].split("_")[1],b.split("/")[-1].split("_")[1])] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment