Skip to content

Commit

Permalink
fix: Remove _get_child_object_display_names which is via get_specs (#…
Browse files Browse the repository at this point in the history
…3430)

* fix: Remove _get_child_object_display_names which is via get_specs

* fix: import

* fix: get_object_names is not available in Fluent <= 24.1

This reverts commit 169dabe.
  • Loading branch information
mkundu1 authored Oct 29, 2024
1 parent cce4bcc commit bd9027e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
21 changes: 12 additions & 9 deletions src/ansys/fluent/core/services/datamodel_se.py
Original file line number Diff line number Diff line change
Expand Up @@ -1514,9 +1514,12 @@ def _get_child_object_display_names(self) -> list[str]:

def get_object_names(self) -> Any:
"""Displays the name of objects within a container."""
return self.service.get_object_names(
self.rules, convert_path_to_se_path(self.path)
)
if self.service.version <= FluentVersion.v241:
return self._get_child_object_display_names()
else:
return self.service.get_object_names(
self.rules, convert_path_to_se_path(self.path)
)

getChildObjectDisplayNames = get_object_names

Expand All @@ -1528,7 +1531,7 @@ def __len__(self) -> int:
int
Count of child objects.
"""
return len(self._get_child_object_display_names())
return len(self.get_object_names())

def __iter__(self) -> Iterator[PyMenu]:
"""Return the next child object.
Expand All @@ -1538,15 +1541,15 @@ def __iter__(self) -> Iterator[PyMenu]:
Iterator[PyMenu]
Iterator of child objects.
"""
for name in self._get_child_object_display_names():
for name in self.get_object_names():
child_path = self.path[:-1]
child_path.append((self.path[-1][0], name))
yield getattr(self.__class__, f"_{self.__class__.__name__}")(
self.service, self.rules, child_path
)

def _get_item(self, key: str) -> PyMenu:
if key in self._get_child_object_display_names():
if key in self.get_object_names():
child_path = self.path[:-1]
child_path.append((self.path[-1][0], key))
return getattr(self.__class__, f"_{self.__class__.__name__}")(
Expand All @@ -1558,7 +1561,7 @@ def _get_item(self, key: str) -> PyMenu:
)

def _del_item(self, key: str) -> None:
if key in self._get_child_object_display_names():
if key in self.get_object_names():
child_path = self.path[:-1]
child_path.append((self.path[-1][0], key))
se_path = convert_path_to_se_path(child_path)
Expand Down Expand Up @@ -2231,13 +2234,13 @@ class PyNamedObjectContainerGeneric(PyNamedObjectContainer):
available."""

def __iter__(self) -> Iterator[PyMenuGeneric]:
for name in self._get_child_object_display_names():
for name in self.get_object_names():
child_path = self.path[:-1]
child_path.append((self.path[-1][0], name))
yield PyMenuGeneric(self.service, self.rules, child_path)

def _get_item(self, key: str) -> PyMenuGeneric:
if key in self._get_child_object_display_names():
if key in self.get_object_names():
child_path = self.path[:-1]
child_path.append((self.path[-1][0], key))
return PyMenuGeneric(self.service, self.rules, child_path)
Expand Down
2 changes: 1 addition & 1 deletion src/ansys/fluent/core/utils/networking.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import logging
import socket
from typing import Any
import urllib
import urllib.request

import grpc
from grpc_health.v1 import health_pb2, health_pb2_grpc
Expand Down
2 changes: 1 addition & 1 deletion src/ansys/fluent/core/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ def __iter__(self) -> Iterator[BaseTask]:
Iterator[BaseTask]
Iterator of child objects.
"""
for name in self._get_child_object_display_names():
for name in self.get_object_names():
yield self[name]

def __getitem__(self, name):
Expand Down

0 comments on commit bd9027e

Please sign in to comment.