<s> try : <EOL> import xml . etree . ElementTree as ET <EOL> except ImportError : <EOL> import xml . etree . cElementTree as ET <EOL> class Argument ( object ) : <EOL> """<STR_LIT>""" <EOL> data_type_boolean = "<STR_LIT>" <EOL> data_type_number = "<STR_LIT>" <EOL> data_type_string = "<STR_LIT>" <EOL> def __init__ ( self , name , description = None , validation = None , <EOL> data_type = data_type_string , required_on_edit = False , required_on_create = False , title = None ) : <EOL> """<STR_LIT>""" <EOL> self . name = name <EOL> self . description = description <EOL> self . validation = validation <EOL> self . data_type = data_type <EOL> self . required_on_edit = required_on_edit <EOL> self . required_on_create = required_on_create <EOL> self . title = title <EOL> def add_to_document ( self , parent ) : <EOL> """<STR_LIT>""" <EOL> arg = ET . SubElement ( parent , "<STR_LIT>" ) <EOL> arg . set ( "<STR_LIT:name>" , self . name ) <EOL> if self . title is not None : <EOL> ET . SubElement ( arg , "<STR_LIT:title>" ) . text = self . title <EOL> if self . description is not None : <EOL> ET . SubElement ( arg , "<STR_LIT:description>" ) . text = self . description <EOL> if self . validation is not None : <EOL> ET . SubElement ( arg , "<STR_LIT>" ) . text = self . validation <EOL> subelements = [ <EOL> ( "<STR_LIT>" , self . data_type ) , <EOL> ( "<STR_LIT>" , self . required_on_edit ) , <EOL> ( "<STR_LIT>" , self . required_on_create ) <EOL> ] <EOL> for name , value in subelements : <EOL> ET . SubElement ( arg , name ) . text = str ( value ) . lower ( ) <EOL> return arg </s>
