#NEWLINE# def validate( localpart ) : #NEWLINE# #INDENT# if ( not localpart ) : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# lparts = localpart . split ( '+' ) #NEWLINE# real_localpart = lparts [ 0 ] #NEWLINE# stripped_localpart = real_localpart . replace ( '.' , '' ) #NEWLINE# l = len ( stripped_localpart ) #NEWLINE# if ( ( l < 6 ) or ( l > 30 ) ) : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# if ( ALPHANUM . match ( stripped_localpart [ 0 ] ) is None ) : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# if ( ALPHANUM . match ( real_localpart [ ( - 1 ) ] ) is None ) : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# return _validate ( real_localpart )