Project

General

Profile

1 17215 mateusz.ko
#!/usr/bin/env python
2
3
## Generates a new version of the "generate_example_workflow_apps.properties"
4
## file that contains paths to all of the example workflows stored in this
5
## project. This is done by scanning the directory tree and searching for
6
## directories that look like they contain workflow definitions.
7
8
from __future__ import print_function
9
10
import os
11
import os.path
12
13 19345 mateusz.ko
dir_with_examples = "src/test/resources/eu/dnetlib/iis/core/examples"
14 17215 mateusz.ko
dirs_to_ignore = [".svn"]
15
output_file = "src/main/scripts/generate_example_workflow_apps.properties"
16
17
def does_contain_example(dir_path):
18
	if os.path.exists(os.path.join(dir_path, "oozie_app")):
19
		return True
20
	else:
21
		return False
22
23 19345 mateusz.ko
examples = []
24 17215 mateusz.ko
25
for root, dirs, files in os.walk(dir_with_examples):
26
	for dir_to_ignore in dirs_to_ignore:
27
		dirs.remove(dir_to_ignore)
28
	dirs_to_remove = []
29
	for dir_ in dirs:
30
		dir_path = os.path.join(root, dir_)
31
		if does_contain_example(dir_path):
32 19345 mateusz.ko
			examples.append(dir_path)
33 17215 mateusz.ko
			dirs_to_remove.append(dir_)
34
	for dir_to_remove in dirs_to_remove:
35
		dirs.remove(dir_to_remove)
36
37 19345 mateusz.ko
examples = sorted(examples)
38 17215 mateusz.ko
with open(output_file, "w") as f:
39 19345 mateusz.ko
	for e in examples:
40
		print(e, file=f)
41 17215 mateusz.ko
	print("# remember to leave '\\n' after the last line\n", file=f)