#NEWLINE# def _add_options( self , sl , enums ) : #NEWLINE# #INDENT# et = type ( value ) #NEWLINE# if ( ( et is Enums ) and enums ) : #NEWLINE# #INDENT# for ( i , name ) in enums . choices : #NEWLINE# #INDENT# opt = self . dtd . Option ( value = i ) #NEWLINE# opt . append ( POM . Text ( name ) ) #NEWLINE# sl . append ( opt ) #NEWLINE# #UNINDENT# return #NEWLINE# #UNINDENT# if ( ( et is dict ) and enums ) : #NEWLINE# #INDENT# for ( key , val ) in enums . items ( ) : #NEWLINE# #INDENT# opt = self . dtd . Optgroup ( label = key ) #NEWLINE# self . _add_options ( opt , val ) #NEWLINE# sl . append ( opt ) #NEWLINE# #UNINDENT# return #NEWLINE# #UNINDENT# if ( ( et is tuple ) and enums ) : #NEWLINE# #INDENT# ( name , value ) = enums #NEWLINE# opt = self . dtd . Option ( value = value ) #NEWLINE# opt . append ( POM . Text ( name ) ) #NEWLINE# return #NEWLINE# #UNINDENT# if ( ( et is list ) and enums ) : #NEWLINE# #INDENT# for item in enums : #NEWLINE# #INDENT# it = type ( item ) #NEWLINE# if ( it is tuple ) : #NEWLINE# #INDENT# opt = self . dtd . Option ( value = item [ 0 ] ) #NEWLINE# opt . append ( POM . Text ( item [ 1 ] ) ) #NEWLINE# if ( ( len ( item ) > 2 ) and item [ 2 ] ) : #NEWLINE# #INDENT# opt . selected = 'selected' #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( it is dict ) : #NEWLINE# #INDENT# for ( key , val ) in item . items ( ) : #NEWLINE# #INDENT# optgrp = self . dtd . Optgroup ( label = key ) #NEWLINE# sl . append ( optgrp ) #NEWLINE# self . _add_options ( optgrp , val ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( it is Enum ) : #NEWLINE# #INDENT# opt = self . dtd . Option ( value = int ( item ) ) #NEWLINE# opt . append ( POM . Text ( item ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( it is list ) : #NEWLINE# #INDENT# self . _add_options ( sl , item ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# opt = self . dtd . Option ( value = item ) #NEWLINE# opt . append ( POM . Text ( item ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# sl . append ( opt ) #NEWLINE# #UNINDENT# return #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# opt = self . dtd . Option ( value = enums ) #NEWLINE# opt . append ( POM . Text ( enums ) ) #NEWLINE# sl . append ( opt ) #NEWLINE# return