#NEWLINE# def _opt( self , dest , **kwds ) : #NEWLINE# #INDENT# if ( ( not dest ) or ( set ( kwds . keys ( ) ) != self . _opt_sig_hash ) ) : #NEWLINE# #INDENT# raise TypeError ( 'Malformed option signature.' ) #NEWLINE# #UNINDENT# for k in ( 'aliases' , 'groups' , 'names' ) : #NEWLINE# #INDENT# kwds [ k ] = list ( kwds [ k ] ) #NEWLINE# #UNINDENT# spec = kwds [ 'spec' ] #NEWLINE# spec [ 'dest' ] = dest #NEWLINE# tf = ( True , False ) #NEWLINE# tfs = '' #NEWLINE# pat = '%(help)s%(tfs)s' #NEWLINE# default = spec . setdefault ( 'default' , NO_DEFAULT ) #NEWLINE# default_type = self . _opt_types . get ( type ( default ) , None ) #NEWLINE# self . _groups_cache [ Groups . ALL ] . add ( dest ) #NEWLINE# for g in kwds [ 'groups' ] : #NEWLINE# #INDENT# self . _groups_cache [ g ] . add ( dest ) #NEWLINE# #UNINDENT# if ( default is True ) : #NEWLINE# #INDENT# self . _groups_cache [ Groups . DEFAULT ] . add ( dest ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( n is False ) : #NEWLINE# #INDENT# self . _groups_cache [ Groups . NODEFAULT ] . add ( dest ) #NEWLINE# #UNINDENT# #UNINDENT# if ( default in tf ) : #NEWLINE# #INDENT# spec [ 'action' ] = 'store_true' #NEWLINE# #UNINDENT# if ( 'action' not in spec ) : #NEWLINE# #INDENT# spec [ 'action' ] = 'store' #NEWLINE# #UNINDENT# if ( 'choices' in spec ) : #NEWLINE# #INDENT# spec [ 'type' ] = 'choice' #NEWLINE# #UNINDENT# if ( 'type' not in spec ) : #NEWLINE# #INDENT# spec [ 'type' ] = default_type #NEWLINE# #UNINDENT# if ( ( default in tf ) or ( default_type is not None ) ) : #NEWLINE# #INDENT# tfs = ' [%default]' #NEWLINE# #UNINDENT# spec [ 'help' ] = ( pat % { #NEWLINE# #INDENT# 'tfs' : tfs , #NEWLINE# 'help' : spec [ 'help' ] , #NEWLINE# #UNINDENT# } ) #NEWLINE# if ( spec [ 'action' ] != 'callback' ) : #NEWLINE# #INDENT# spec [ 'callback' ] = self . _opt_set #NEWLINE# spec [ 'callback_kwargs' ] = { #NEWLINE# #INDENT# '_action' : spec [ 'action' ] , #NEWLINE# '_cache' : kwds , #NEWLINE# #UNINDENT# } #NEWLINE# spec [ 'action' ] = 'callback' #NEWLINE# #UNINDENT# for ( k , nk ) in ( ( 'names' , 'nonames' ) , ( 'aliases' , 'noaliases' ) ) : #NEWLINE# #INDENT# no = kwds [ nk ] = list ( ) #NEWLINE# for n in kwds [ k ] : #NEWLINE# #INDENT# for repl in [ ( '--with' , '--without' , 1 ) , ( '--enable' , '--disable' , 1 ) , ( '--' , '--no-' , 1 ) ] : #NEWLINE# #INDENT# rev = n . replace ( * repl ) #NEWLINE# if ( rev != n ) : #NEWLINE# #INDENT# no . append ( rev ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# self . _order . append ( dest ) #NEWLINE# self . _cache [ dest ] = kwds