Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save hltbra/253442 to your computer and use it in GitHub Desktop.
Save hltbra/253442 to your computer and use it in GitHub Desktop.
=====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