Created
September 2, 2014 13:47
-
-
Save mengzhuo/caa1a2eaad818c2c3606 to your computer and use it in GitHub Desktop.
configure module (reloadable)
This file contains 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
#!/usr/bin/env python | |
# encoding: utf-8 | |
import os | |
from ConfigParser import SafeConfigParser | |
PREFIX = 'ZTY' | |
setting = SafeConfigParser() | |
setting.read(['/etc/zty-site.conf', | |
'~/zty-site.conf']) | |
for k,v in os.environ.iteritems(): | |
if k.startswith(PREFIX): | |
section, _, option = k.partition('_') | |
setting.set(section, option, v) | |
get = setting.get | |
getboolean = setting.getboolean | |
getfloat = setting.getfloat | |
getint = setting.getint |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment