Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion src/ansys/fluent/core/meta.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Metaclasses used in various explicit classes in PyFluent."""
from abc import ABCMeta
from collections.abc import MutableMapping
from functools import partial
from pprint import pformat

# pylint: disable=unused-private-member
Expand Down Expand Up @@ -30,6 +31,24 @@ def __get__(self, obj, objtype=None):
return self.function(obj)


class Command:

def __init__(self, command):
self.command = command

def __set_name__(self, obj, name):
if not hasattr(obj, "command"):
obj.commands = {}
# TODO: Apply the proper implementation of command arguments
# so as to match the implementation of settings
# args = {"x": {'type': "int", "is_active": True}}
# args = inspect.getargspec(self.command)
obj.commands[name] = {}

def __get__(self, obj, obj_type=None):
return partial(self.command, obj)


class PyLocalBaseMeta(type):
@classmethod
def __create_get_parent_by_type(cls):
Expand Down Expand Up @@ -109,7 +128,7 @@ def wrapper(self, parent, api_helper):
value_annotation = annotations.get("_value")
else:
value_annotation = annotations.get("value")
self._type = value_annotation
self.type = value_annotation
reset_on_change = (
hasattr(self, "_reset_on_change")
and getattr(self, "_reset_on_change")()
Expand Down Expand Up @@ -172,6 +191,7 @@ def __create_init(cls):
def wrapper(self, parent, api_helper):
self._parent = parent
self._api_helper = api_helper(self)
self.type = "object"

def update(clss):
for name, cls in clss.__dict__.items():
Expand Down Expand Up @@ -297,6 +317,7 @@ def wrapper(self, name, parent, api_helper):
self._name = name
self._api_helper = api_helper(self)
self._parent = parent
self.type = "object"

def update(clss):
for name, cls in clss.__dict__.items():
Expand Down Expand Up @@ -339,6 +360,7 @@ def __init__(self, parent, object_class, api_helper):
self.__object_class = object_class
self.__collection: dict = {}
self.__api_helper = api_helper
self.type = "named-object"

def __iter__(self):
return iter(self.__collection)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from ansys.fluent.core.meta import (
Attribute,
Command,
PyLocalNamedObjectMetaAbstract,
PyLocalObjectMeta,
PyLocalPropertyMeta,
Expand Down Expand Up @@ -34,6 +35,7 @@ def _post_display(self):
class GraphicsDefn(BasePostObjectDefn, metaclass=PyLocalNamedObjectMetaAbstract):
"""Abstract base class for graphics objects."""

@Command
@abstractmethod
def display(self, plotter_id: Optional[str] = None):
"""Display graphics.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ def __init__(self, session, child, module, local_surfaces_provider=None):
self, "Surfaces", []
)

@property
def type(self):
return "object"

def _init_module(self, obj, mod):
from ansys.fluent.core.post_objects.post_helper import PostAPIHelper

Expand Down