Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- substre = re.compile('\$\{([^:]+):([^\}]+)\}')
- class MyConfigParser(SafeConfigParser):
- def get(self,*a,**kw):
- value = super().get(*a,**kw)
- for m in substre.finditer(value):
- envvar = m.group(1)
- default = m.group(2)
- match = m.group()
- if envvar in os.environ:
- value = value.replace(match,os.environ[envvar])
- return value
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement