#NEWLINE# def _get_user_case_fields( commcare_user ) : #NEWLINE# #INDENT# def valid_element_name( name ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# ElementTree . fromstring ( '<{}/>' . format ( name ) ) #NEWLINE# return True #NEWLINE# #UNINDENT# except ElementTree . ParseError : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# #UNINDENT# fields = { k : v for ( k , v ) in commcare_user . user_data . items ( ) if valid_element_name ( k ) } #NEWLINE# fields . update ( { #NEWLINE# #INDENT# 'name' : ( commcare_user . name or commcare_user . raw_username ) , #NEWLINE# 'username' : commcare_user . raw_username , #NEWLINE# 'email' : commcare_user . email , #NEWLINE# 'language' : ( commcare_user . language or '' ) , #NEWLINE# 'phone_number' : ( commcare_user . phone_number or '' ) , #NEWLINE# #UNINDENT# } ) #NEWLINE# return fields