mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Add a new pass-through module for resinsight_classes.py to aid documentation
This commit is contained in:
committed by
Magne Sjaastad
parent
861577922a
commit
a2ee4c8fef
@@ -15,8 +15,6 @@ import PdmObject_pb2
|
||||
import PdmObject_pb2_grpc
|
||||
import Commands_pb2
|
||||
import Commands_pb2_grpc
|
||||
import resinsight_classes as ClassList
|
||||
|
||||
|
||||
def camel_to_snake(name):
|
||||
s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', name)
|
||||
@@ -214,10 +212,11 @@ class PdmObjectBase:
|
||||
values.append(self.__convert_from_grpc_value(string))
|
||||
return values
|
||||
|
||||
def __from_pb2_to_resinsight_classes(self, pb2_object_list, super_class_definition):
|
||||
def __from_pb2_to_generated_classes(self, pb2_object_list, super_class_definition):
|
||||
pdm_object_list = []
|
||||
from .generated.generated_classes import class_from_keyword
|
||||
for pb2_object in pb2_object_list:
|
||||
child_class_definition = ClassList.class_from_keyword(pb2_object.class_keyword)
|
||||
child_class_definition = class_from_keyword(pb2_object.class_keyword)
|
||||
if child_class_definition is None:
|
||||
child_class_definition = super_class_definition
|
||||
|
||||
@@ -241,7 +240,7 @@ class PdmObjectBase:
|
||||
object=self._pb2_object, child_keyword=class_keyword)
|
||||
object_list = self._pdm_object_stub.GetDescendantPdmObjects(
|
||||
request).objects
|
||||
return self.__from_pb2_to_resinsight_classes(object_list, class_definition)
|
||||
return self.__from_pb2_to_generated_classes(object_list, class_definition)
|
||||
except grpc.RpcError as e:
|
||||
if e.code() == grpc.StatusCode.NOT_FOUND:
|
||||
return [] # Valid empty result
|
||||
@@ -258,7 +257,7 @@ class PdmObjectBase:
|
||||
child_field=child_field)
|
||||
try:
|
||||
object_list = self._pdm_object_stub.GetChildPdmObjects(request).objects
|
||||
return self.__from_pb2_to_resinsight_classes(object_list, class_definition)
|
||||
return self.__from_pb2_to_generated_classes(object_list, class_definition)
|
||||
except grpc.RpcError as e:
|
||||
if e.code() == grpc.StatusCode.NOT_FOUND:
|
||||
return []
|
||||
@@ -272,12 +271,13 @@ class PdmObjectBase:
|
||||
assert(inspect.isclass(class_definition))
|
||||
|
||||
class_keyword = class_definition.__name__
|
||||
from .generated.generated_classes import class_from_keyword
|
||||
|
||||
request = PdmObject_pb2.PdmParentObjectRequest(
|
||||
object=self._pb2_object, parent_keyword=class_keyword)
|
||||
try:
|
||||
pb2_object = self._pdm_object_stub.GetAncestorPdmObject(request)
|
||||
child_class_definition = ClassList.class_from_keyword(pb2_object.class_keyword)
|
||||
child_class_definition = class_from_keyword(pb2_object.class_keyword)
|
||||
|
||||
if child_class_definition is None:
|
||||
child_class_definition = class_definition
|
||||
@@ -351,7 +351,9 @@ class PdmObjectBase:
|
||||
|
||||
pb2_object = self._pdm_object_stub.CallPdmObjectMethod(request)
|
||||
|
||||
child_class_definition = ClassList.class_from_keyword(pb2_object.class_keyword)
|
||||
from .generated.generated_classes import class_from_keyword
|
||||
|
||||
child_class_definition = class_from_keyword(pb2_object.class_keyword)
|
||||
if child_class_definition is None:
|
||||
return None
|
||||
|
||||
|
||||
Reference in New Issue
Block a user