Created
December 10, 2009 16:45
-
-
Save hltbra/253442 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
=====buildout.cfg====== | |
[buildout] | |
directory = hello_world.py | |
======================= | |
=====hello_world.py==== | |
print 'hello world' | |
======================= | |
======runner.cfg======= | |
<runner> | |
python ${buildout:directory} | |
</runner> | |
======================= | |
=======runner.py======= | |
from ConfigParser import ConfigParser | |
import re | |
conf = open('runner.conf') | |
new_conf = [] | |
parser = ConfigParser() | |
parser.read('buildout.cfg') | |
for line in conf.readlines(): | |
new_line = line | |
for section, value in re.findall(r'\${(\w+):(\w+)}', line): | |
new_line = line.replace('${%s:%s}' % (section, value), | |
parser.get(section, value)) | |
new_conf.append(new_line) | |
print ''.join(new_conf) | |
=============================== |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment