Project

General

Profile

1
#!/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
dir_with_examples = "src/test/resources/eu/dnetlib/iis/core/examples"
14
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
examples = []
24

    
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
			examples.append(dir_path)
33
			dirs_to_remove.append(dir_)
34
	for dir_to_remove in dirs_to_remove:
35
		dirs.remove(dir_to_remove)
36

    
37
examples = sorted(examples)
38
with open(output_file, "w") as f:
39
	for e in examples:
40
		print(e, file=f)
41
	print("# remember to leave '\\n' after the last line\n", file=f)
(7-7/7)