def descendants(self, class_keyword): """Get a list of all project tree descendants matching the class keyword Arguments: class_keyword[str]: A class keyword matching the type of class wanted Returns: A list of PdmObjects matching the keyword provided """ request = PdmObject_pb2.PdmDescendantObjectRequest( object=self._pb2_object, child_keyword=class_keyword) object_list = self._pdm_object_stub.GetDescendantPdmObjects( request).objects child_list = [] for pdm_object in object_list: child_list.append(PdmObject(pdm_object, self._channel)) return child_list
def descendants(self, class_definition): """Get a list of all project tree descendants matching the class keyword Arguments: class_definition[class]: A class definition matching the type of class wanted Returns: A list of PdmObjects matching the class_definition """ assert(inspect.isclass(class_definition)) class_keyword = class_definition.__name__ try: request = PdmObject_pb2.PdmDescendantObjectRequest( object=self._pb2_object, child_keyword=class_keyword) object_list = self._pdm_object_stub.GetDescendantPdmObjects( request).objects return self.__from_pb2_to_pdm_objects(object_list, class_definition) except grpc.RpcError as e: if e.code() == grpc.StatusCode.NOT_FOUND: return [] # Valid empty result raise e