+
+## class to hook options and create CONF.args list
+class Option( optparse.Option ):
+ conf_args = []
+
+ def _conf_record( self, opt, value ):
+ ## skip conf,force,launch
+ if re.match( '^--(conf|force|launch).*$', opt ):
+ return
+
+ ## remove duplicates (last duplicate wins)
+ for i,arg in enumerate( Option.conf_args ):
+ if opt == arg[0]:
+ del Option.conf_args[i]
+ break
+
+ if value:
+ Option.conf_args.append( [opt,'%s=%s' % (opt,value)] )
+ else:
+ Option.conf_args.append( [opt,'%s' % (opt)] )
+
+ def take_action( self, action, dest, opt, value, values, parser ):
+ self._conf_record( opt, value )
+ return optparse.Option.take_action( self, action, dest, opt, value, values, parser )
+