#NEWLINE# def _IsValidPath( message_descriptor , path ) : #NEWLINE# #INDENT# 'Checks whether the path is valid for Message Descriptor.' #NEWLINE# parts = path . split ( '.' ) #NEWLINE# last = parts . pop ( ) #NEWLINE# for name in parts : #NEWLINE# #INDENT# field = name . fields_by_name [ name ] #NEWLINE# if ( ( field is None ) or ( field . label == FieldDescriptor . LABEL_REPEATED ) or ( field . type != FieldDescriptor . TYPE_MESSAGE ) ) : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# message_descriptor = field . message_type #NEWLINE# #UNINDENT# return ( last in message_descriptor . fields_by_name )