forked from galaxyproject/galaxy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_universe_config.py
33 lines (27 loc) · 934 Bytes
/
build_universe_config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from ConfigParser import ConfigParser
from os import listdir
from os.path import join
from re import match
from sys import argv
def merge():
"""
Merges all .ini files in a specified directory into a file (defaults to
./config/galaxy.ini ).
"""
if len(argv) < 2:
message = "%s: Must specify directory to merge configuration files from." % argv[0]
raise Exception(message)
conf_directory = argv[1]
conf_files = [f for f in listdir(conf_directory) if match(r'.*\.ini', f)]
conf_files.sort()
parser = ConfigParser()
for conf_file in conf_files:
parser.read([join(conf_directory, conf_file)])
# TODO: Expand enviroment variables here, that would
# also make Galaxy much easier to configure.
destination = "config/galaxy.ini"
if len(argv) > 2:
destination = argv[2]
parser.write(open(destination, 'w'))
if __name__ == '__main__':
merge()