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
1 changed files with 12 additions and 8 deletions

View File

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