#NEWLINE# def add_element( self , element , id = None , name = None , value = None , is_custom = False ) : #NEWLINE# #INDENT# element = self . resource . createElement ( element ) #NEWLINE# if ( id is not None ) : #NEWLINE# #INDENT# if ( type ( id ) . __name__ == 'int' ) : #NEWLINE# #INDENT# element . setAttribute ( 'id' , ( '%d' % id ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# element . setAttribute ( 'id' , id ) #NEWLINE# #UNINDENT# #UNINDENT# if ( name is not None ) : #NEWLINE# #INDENT# element . setAttribute ( 'name' , name ) #NEWLINE# #UNINDENT# if ( value is not None ) : #NEWLINE# #INDENT# if ( type ( value ) . __name__ == 'int' ) : #NEWLINE# #INDENT# val = self . resource . createTextNode ( ( '%d' % value ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# val = self . resource . createTextNode ( value ) #NEWLINE# #UNINDENT# if is_custom : #NEWLINE# #INDENT# valEl = self . resource . createElement ( 'value' ) #NEWLINE# valEl . appendChild ( val ) #NEWLINE# element . appendChild ( valEl ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# element . appendChild ( val ) #NEWLINE# #UNINDENT# #UNINDENT# if is_custom : #NEWLINE# #INDENT# customEl = self . resource . getElementsByTagName ( 'custom_fields' ) #NEWLINE# if ( len ( customEl ) > 0 ) : #NEWLINE# #INDENT# customEl [ 0 ] . appendChild ( element ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# customEl = self . resource . createElement ( 'custom_fields' ) #NEWLINE# customEl . setAttribute ( 'type' , 'array' ) #NEWLINE# customEl . appendChild ( element ) #NEWLINE# self . resource . documentElement . appendChild ( is_custom ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# self . resource . documentElement . appendChild ( element )