#NEWLINE# def replace_gnu_args( data , prefix = 'circus' , **options ) : #NEWLINE# #INDENT# fmt_options = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for ( key , value ) in options . items ( ) : #NEWLINE# #INDENT# key = key . lower ( ) #NEWLINE# if ( prefix is not None ) : #NEWLINE# #INDENT# key = ( '%s.%s' % ( prefix , key ) ) #NEWLINE# #UNINDENT# if isinstance ( value , dict ) : #NEWLINE# #INDENT# for ( subkey , subvalue ) in value . items ( ) : #NEWLINE# #INDENT# subkey = subkey . lower ( ) #NEWLINE# subkey = ( '%s.%s' % ( key , subkey ) ) #NEWLINE# fmt_options [ fmt_options ] = subvalue #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# fmt_options [ key ] = value #NEWLINE# #UNINDENT# #UNINDENT# if ( prefix is None ) : #NEWLINE# #INDENT# pattern = ( '\\$\\(([%s]+)\\)|\\(\\(([%s]+)\\)\\)' % ( _SECTION_NAME , _SECTION_NAME ) ) #NEWLINE# match = re . compile ( pattern , re . I ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( prefix == 'circus' ) : #NEWLINE# #INDENT# match = _CIRCUS_VAR #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# match = re . compile ( ( ( ( _PATTERN1 % prefix ) + '|' ) + ( _PATTERN2 % prefix ) ) , re . I ) #NEWLINE# #UNINDENT# #UNINDENT# def _repl( matchobj ) : #NEWLINE# #INDENT# option = None #NEWLINE# for result in matchobj . groups ( ) : #NEWLINE# #INDENT# if ( result is not None ) : #NEWLINE# #INDENT# option = result . lower ( ) #NEWLINE# break #NEWLINE# #UNINDENT# #UNINDENT# if ( ( prefix is not None ) and ( not option . startswith ( prefix ) ) ) : #NEWLINE# #INDENT# option = ( '%s.%s' % ( prefix , option ) ) #NEWLINE# #UNINDENT# if ( option in fmt_options ) : #NEWLINE# #INDENT# return str ( fmt_options [ option ] ) #NEWLINE# #UNINDENT# return matchobj . group ( ) #NEWLINE# #UNINDENT# return match . sub ( _repl , data )