Files
ResInsight/GrpcInterface/Python/rips/__init__.py
T
Kristian Bendiksen 01ceb57323 #14001 Python: Drop hand-written PropertyType, use auto-generated PropertyType
Consolidate the hand-written PropertyType / NNCPropertyType enums in
enums.py into the auto-generated StrEnum classes that already exist in
generated_classes.py. enums.py and all its imports are removed.

The auto-generated class for caf::AppEnum<RiaDefines::ResultCatType>
was named "ResultType" because the existing scriptable m_resultType
fields used keyword "ResultType". Switch those fields to
CAF_PDM_InitScriptableFieldWithScriptKeywordNoDefault, keeping the XML
keyword "ResultType" (so project files still load) but exposing the
script keyword as "PropertyType". The generator now emits a single
PropertyType StrEnum that:

- matches the proto PropertyType for setters (FLOAT/INTEGER aside, the
  members callers actually use are identical),
- gains ALLAN_DIAGRAMS that the C++ side already knew about,
- loses the proto-only REMOVED/UNDEFINED sentinels (unused in any
  Python caller).

rips.NNCPropertyType was exported but unreferenced anywhere — dropped.

Updated Python callers:
- rips.ResultType.X -> rips.PropertyType.X across examples and tests.
- result_type= kwarg / .result_type attribute -> property_type /
  .property_type (the script keyword change renamed those everywhere
  the affected PdmObject fields are accessed from Python).
- view.apply_cell_result's hand-written wrapper now takes property_type
  instead of result_type and forwards via cell_result.property_type.

All 271 Python tests pass, ruff and clang-format clean.
2026-05-26 08:23:28 +02:00

53 lines
1.9 KiB
Python

import logging
import os
import sys
from typing import List
# Configure null handler to prevent "No handler found" warnings
logging.getLogger("rips").addHandler(logging.NullHandler())
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "generated"))
from .resinsight_classes import * # noqa: F403, E402
from .case import Case as Case, EclipseCase as EclipseCase, GeoMechCase as GeoMechCase # noqa: E402
from .grid import Grid as Grid # noqa: E402
from .instance import Instance as Instance # noqa: E402
from .view import View as View # noqa: E402
from .project import Project as Project # noqa: E402
from .plot import Plot as Plot, PlotWindow as PlotWindow # noqa: E402
from .contour_map import ( # noqa: E402
EclipseContourMap as EclipseContourMap,
GeoMechContourMap as GeoMechContourMap,
)
from .well_log_plot import WellLogPlot as WellLogPlot # noqa: E402
from .well_path import WellPath as WellPath # noqa: E402
from . import well_log as well_log # noqa: F401, E402
from . import well_path_collection as well_path_collection # noqa: F401, E402
from .simulation_well import SimulationWell as SimulationWell # noqa: E402
from .exception import RipsError as RipsError # noqa: E402
from .surface import RegularSurface as RegularSurface # noqa: E402
from . import well_events as well_events # noqa: F401, E402
from . import category_mapping as category_mapping # noqa: F401, E402
__all__: List[str] = []
for key in class_dict(): # noqa: F405
__all__.append(key)
# Add classes not in resinsight_classes
__all__.append("Grid")
__all__.append("Instance")
# PropertyType, PropertyDataType, and PorosityModelType are auto-generated
# StrEnum classes (driven by their caf::AppEnum<T> registrations) that the
# wildcard import above pulls in but class_dict() does not list.
for _enum_name in (
"PorosityModelType",
"PropertyDataType",
"PropertyType",
):
if _enum_name not in __all__:
__all__.append(_enum_name)
__all__.sort()