#NEWLINE# @ classmethod #NEWLINE# def Canonicalize( cls , identity_key ) : #NEWLINE# #INDENT# 'Returns the canonical form of the given identity key.' #NEWLINE# for prefix in [ 'Email:' , 'Phone:' , 'FacebookGraph:' , 'Local:' , 'VF:' ] : #NEWLINE# #INDENT# if identity_key . startswith ( prefix ) : #NEWLINE# #INDENT# value = identity_key [ len ( prefix ) : ] #NEWLINE# if ( prefix == 'Email:' ) : #NEWLINE# #INDENT# canonical_value = Identity . CanonicalizeEmail ( value ) #NEWLINE# if ( value is not canonical_value ) : #NEWLINE# #INDENT# identity_key = ( prefix + canonical_value ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( prefix == 'Phone:' ) : #NEWLINE# #INDENT# canonical_value = Identity . CanonicalizePhone ( value ) #NEWLINE# if ( value is not canonical_value ) : #NEWLINE# #INDENT# identity_key = ( prefix + canonical_value ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return identity_key #NEWLINE# #UNINDENT# #UNINDENT# raise InvalidRequestError ( ( 'Scheme for identity %s unknown.' % identity_key ) )