From bd9027e2882d95c6af38e2b4c89cdd84f338e1fb Mon Sep 17 00:00:00 2001 From: Mainak Kundu <94432368+mkundu1@users.noreply.github.com> Date: Tue, 29 Oct 2024 00:44:38 -0400 Subject: [PATCH] fix: Remove _get_child_object_display_names which is via get_specs (#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 169dabef4ccf0048c9f1c8b00a8ec57334ce7209. --- .../fluent/core/services/datamodel_se.py | 21 +++++++++++-------- src/ansys/fluent/core/utils/networking.py | 2 +- src/ansys/fluent/core/workflow.py | 2 +- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/ansys/fluent/core/services/datamodel_se.py b/src/ansys/fluent/core/services/datamodel_se.py index 09329129cb2..e32aad024ef 100644 --- a/src/ansys/fluent/core/services/datamodel_se.py +++ b/src/ansys/fluent/core/services/datamodel_se.py @@ -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 @@ -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. @@ -1538,7 +1541,7 @@ 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__}")( @@ -1546,7 +1549,7 @@ def __iter__(self) -> Iterator[PyMenu]: ) 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__}")( @@ -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) @@ -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) diff --git a/src/ansys/fluent/core/utils/networking.py b/src/ansys/fluent/core/utils/networking.py index 9161f61e3df..003e1713808 100644 --- a/src/ansys/fluent/core/utils/networking.py +++ b/src/ansys/fluent/core/utils/networking.py @@ -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 diff --git a/src/ansys/fluent/core/workflow.py b/src/ansys/fluent/core/workflow.py index 9e65cb5a847..8f1c19c443b 100644 --- a/src/ansys/fluent/core/workflow.py +++ b/src/ansys/fluent/core/workflow.py @@ -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):