Created
December 23, 2015 00:50
-
-
Save mpurzynski/a9ab25218dad4fe57779 to your computer and use it in GitHub Desktop.
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
import os | |
import sys | |
import ConfigParser | |
configfile = './example.conf' | |
try: | |
if os.path.exists(configfile): | |
Config = ConfigParser.ConfigParser() | |
Config.read(configfile) | |
sections = Config.sections() | |
for section in sections: | |
if section is not None: | |
print(section) | |
options = Config.options(section) | |
for option in options: | |
if option is not None: | |
print(option, Config.get(section, option)) | |
except Exception as e: | |
sys.stderr.write('Something is seriously fucked up, python thrown up and the exception is: {0}\n'.format(e)) | |
sys.stderr.write('Fix your config file. Or your script. Or your libs. Have a nice day. Your beloved script.\n') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment