Move to use a static registry of scriptable classes

This commit is contained in:
Gaute Lindkvist
2020-02-24 15:42:23 +01:00
parent 50ae160e2d
commit d95f3a349d
34 changed files with 270 additions and 145 deletions

View File

@@ -78,6 +78,7 @@ def copy_from(self, object):
for attribute in dir(object):
if not attribute.startswith('__'):
value = getattr(object, attribute)
# This is crucial to avoid overwriting methods
if not callable(value):
setattr(self, attribute, value)

View File

@@ -90,12 +90,7 @@ def cases(self):
Returns:
A list of rips Case objects
"""
pdm_objects = self.descendants(Case.__name__)
cases = []
for pdm_object in pdm_objects:
cases.append(pdm_object.cast(Case))
return cases
return self.descendants(Case)
@add_method(Project)
def case(self, case_id):
@@ -142,11 +137,7 @@ def create_grid_case_group(self, case_paths):
@add_method(Project)
def views(self):
"""Get a list of views belonging to a project"""
pdm_objects = self.descendants("ReservoirView")
view_list = []
for pdm_object in pdm_objects:
view_list.append(View(pdm_object))
return view_list
return self.descendants(View)
@add_method(Project)
def view(self, view_id):

View File

@@ -7,11 +7,11 @@ import rips.generated.Commands_pb2 as Cmd
import rips.case # Circular import of Case, which already imports View. Use full name.
from rips.pdmobject import add_method
from rips.generated.pdm_objects import View, ViewWindow, ReservoirView, GeoMechView
from rips.generated.pdm_objects import View, ViewWindow, EclipseView, GeoMechView
@add_method(View)
def is_eclipse_view(self):
return isinstance(self, ReservoirView)
return isinstance(self, EclipseView)
@add_method(View)
def is_geomech_view(self):