Optional -c / --config option with argparse for seperate config files.

pull/5/head
David Trail 12 years ago
parent 896abd5a54
commit 15c5d3abf2

@ -2,10 +2,18 @@
import praw import praw
import ConfigParser import ConfigParser
import argparse
from datetime import datetime, timedelta from datetime import datetime, timedelta
parser = argparse.ArgumentParser()
parser.add_argument('-c', '--config', help="config file to use instead of shreddit.cfg")
args = parser.parse_args()
config = ConfigParser.RawConfigParser() config = ConfigParser.RawConfigParser()
config.read('shreddit.cfg') if args.config:
config.read(args.config)
else:
config.read('shreddit.cfg')
hours = config.getint('main', 'hours') hours = config.getint('main', 'hours')
whitelist = config.get('main', 'whitelist') whitelist = config.get('main', 'whitelist')

Loading…
Cancel
Save