+ optparser.add_option('-c', '--config', dest='configfile',
+ default='/etc/hippotat/config')
+
+ def ds_by_detail(od,os,detail_level,op):
+ global debug_set
+ debug_set = set([df for df in DBG.iterconstants() if df <= detail_level])
+
+ def ds_one(mutator,df, od,os,value,op):
+ mutator(df)
+
+ optparser.add_option('-D', '--debug',
+ default=debug_def_detail.name,
+ type='choice',
+ choices=[dl.name for dl in DBG.iterconstants()],
+ action='callback',
+ callback= ds_by_detail)
+
+ optparser.add_option('--no-debug',
+ nargs=0,
+ action='callback',
+ callback= partial(ds_by_detail,DBG.INIT))
+
+ for df in DBG.iterconstants():
+ optparser.add_option('--debug-'+df.name,
+ action='callback',
+ callback= partial(ds_one, debug_set.add, df))
+ optparser.add_option('--no-debug-'+df.name,
+ action='callback',
+ callback= partial(ds_one, debug_set.discard, df))
+
+ (opts, args) = optparser.parse_args()
+ if len(args): optparser.error('no non-option arguments please')
+
+ re = regexp.compile('#.*')
+ cfg.read_string(re.sub('', defcfg))
+ cfg.read(opts.configfile)
+