from configparser import *, light exception handling in initial value load

This commit is contained in:
Brian S. Stephan 2010-07-24 10:12:00 -05:00
parent e792c22a8e
commit 398514a422

View File

@ -1,16 +1,20 @@
#!/usr/bin/env python3.1 #!/usr/bin/env python3.1
import configparser from configparser import *
import os import os
import sys
config = configparser.ConfigParser() config = ConfigParser()
config.read([os.path.expanduser('~/.dr.botzo.cfg'), 'dr.botzo.cfg']) config.read([os.path.expanduser('~/.dr.botzo.cfg'), 'dr.botzo.cfg'])
# load connection info try:
server = config.get('IRC', 'server') # load connection info
port = config.getint('IRC', 'port') server = config.get('IRC', 'server')
channel = config.get('IRC', 'channel') port = config.getint('IRC', 'port')
nick = config.get('IRC', 'nick') channel = config.get('IRC', 'channel')
ircname = config.get('IRC', 'name') nick = config.get('IRC', 'nick')
ircname = config.get('IRC', 'name')
except NoSectionError as e:
sys.exit(str(e))
# vi:tabstop=4:expandtab:autoindent # vi:tabstop=4:expandtab:autoindent