+
+ def dfs_less_detailed(dl):
+ return [df for df in DBG.iterconstants() if df <= dl]
+
+ def ds_default(od,os,dl,op):
+ global debug_set
+ debug_set = set(dfs_less_detailed(debug_def_detail))
+
+ def ds_select(od,os, spec, op):
+ last_df = next(DBG.iterconstants())
+ mutator = debug_set.add
+
+ for it in spec.split(','):
+
+ if not len(it):
+ for df in dfs_less_detailed(last_df):
+ mutator(df)
+ continue
+
+ if it.startswith('-'):
+ mutator = debug_set.discard
+ it = it[1:]
+ else:
+ mutator = debug_set.add
+
+ try:
+ df = DBG.lookupByName(it)
+ except ValueError:
+ optparser.error('unknown debug flag %s in --debug-select' % it)
+ mutator(df)
+ last_df = df
+
+ optparser.add_option('-D', '--debug',
+ nargs=0,
+ action='callback',
+ help='enable default debug (to stdout)',
+ callback= ds_default)
+
+ optparser.add_option('--debug-select',
+ nargs=1,
+ type='string',
+ metavar='[-]DFLAG[,],...',
+ help=
+'''enable (or with -, disable) each specified DFLAG;
+empty entry means do the same for all DFLAGS "more interesting"
+than the last (or, all DFLAGs)''',
+ action='callback',
+ callback= ds_select)
+