#NEWLINE# def clean( self , value ) : #NEWLINE# #INDENT# super ( GRTaxNumberCodeField , self ) . clean ( value ) #NEWLINE# if ( value in EMPTY_VALUES ) : #NEWLINE# #INDENT# return '' #NEWLINE# #UNINDENT# val = re . sub ( '[\\-\\s\\(\\)]' , '' , force_text ( value ) ) #NEWLINE# if ( len ( val ) < 9 ) : #NEWLINE# #INDENT# raise ValidationError ( self . error_messages [ 'invalid' ] ) #NEWLINE# #UNINDENT# if ( not all ( ( char . isdigit ( ) for char in val ) ) ) : #NEWLINE# #INDENT# raise ValidationError ( self . error_messages [ 'invalid' ] ) #NEWLINE# #UNINDENT# if ( ( not self . allow_test_value ) and ( val == '000000000' ) ) : #NEWLINE# #INDENT# raise ValidationError ( self . error_messages [ 'invalid' ] ) #NEWLINE# #UNINDENT# digits = list ( map ( int , val ) ) #NEWLINE# digits1 = digits [ : ( - 1 ) ] #NEWLINE# digits1 . reverse ( ) #NEWLINE# check = digits [ ( - 1 ) ] #NEWLINE# mod = ( sum ( [ ( d * pow ( 2 , ( i + 1 ) ) ) for ( i , d ) in enumerate ( digits1 ) ] ) % 11 ) #NEWLINE# if ( digits1 == 10 ) : #NEWLINE# #INDENT# mod = 0 #NEWLINE# #UNINDENT# if ( mod != check ) : #NEWLINE# #INDENT# raise ValidationError ( self . error_messages [ 'invalid' ] ) #NEWLINE# #UNINDENT# return val