Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved the way the information are plotted from the __str__ methods #3845

Merged
merged 6 commits into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from 4 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
2 changes: 2 additions & 0 deletions _unittest/test_01_Design.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ def test_08_objects(self):
print(self.aedtapp.logger)
print(self.aedtapp.variable_manager)
print(self.aedtapp.materials)
print(self.aedtapp)
assert self.aedtapp.info

def test_09_set_objects_deformation(self):
assert self.aedtapp.modeler.set_objects_deformation(["inner"])
Expand Down
47 changes: 39 additions & 8 deletions pyaedt/application/Design.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,36 @@

"""

def __str__(self):
pyaedt_details = " pyaedt API\n"
pyaedt_details += "pyaedt running AEDT Version {} \n".format(settings.aedt_version)
pyaedt_details += "Running {} tool in AEDT\n".format(self.design_type)
pyaedt_details += "Solution Type: {} \n".format(self.solution_type)
pyaedt_details += "Project Name: {} Design Name {} \n".format(self.project_name, self.design_name)
@property
def _pyaedt_details(self):
import platform

Check warning on line 108 in pyaedt/application/Design.py

View check run for this annotation

Codecov / codecov/patch

pyaedt/application/Design.py#L108

Added line #L108 was not covered by tests

from pyaedt import __version__ as pyaedt_version

Check warning on line 110 in pyaedt/application/Design.py

View check run for this annotation

Codecov / codecov/patch

pyaedt/application/Design.py#L110

Added line #L110 was not covered by tests

_p_dets = {

Check warning on line 112 in pyaedt/application/Design.py

View check run for this annotation

Codecov / codecov/patch

pyaedt/application/Design.py#L112

Added line #L112 was not covered by tests
"PyAEDT Version": pyaedt_version,
"Product": "Ansys Electronics Desktop {}".format(settings.aedt_version),
"Design Type": self.design_type,
"Solution Type": self.solution_type,
"Project Name": self.project_name,
"Design Name": self.design_name,
"Project Path": "",
}
if self._oproject:
pyaedt_details += 'Project Path: "{}" \n'.format(self.project_path)
return pyaedt_details
_p_dets["Project Path"] = self.project_file
_p_dets["Platform"] = platform.platform()
_p_dets["Python Version"] = platform.python_version()
_p_dets["AEDT Process ID"] = self.desktop_class.aedt_process_id
_p_dets["AEDT GRPC Port"] = self.desktop_class.port
return _p_dets

Check warning on line 127 in pyaedt/application/Design.py

View check run for this annotation

Codecov / codecov/patch

pyaedt/application/Design.py#L122-L127

Added lines #L122 - L127 were not covered by tests

def __str__(self):
return "\n".join(

Check warning on line 130 in pyaedt/application/Design.py

View check run for this annotation

Codecov / codecov/patch

pyaedt/application/Design.py#L130

Added line #L130 was not covered by tests
[
"{}:".format(each_name).ljust(25) + "{}".format(each_attr).ljust(25)
for each_name, each_attr in self._pyaedt_details.items()
]
)

def __exit__(self, ex_type, ex_value, ex_traceback):
if ex_type:
Expand All @@ -133,6 +154,16 @@
self.variable_manager[variable_name] = variable_value
return True

@property
def info(self):
"""Dictionary of the PyAEDT session information.

Returns
-------
dict
"""
return self._pyaedt_details

Check warning on line 165 in pyaedt/application/Design.py

View check run for this annotation

Codecov / codecov/patch

pyaedt/application/Design.py#L165

Added line #L165 was not covered by tests

def _init_design(self, project_name, design_name, solution_type=None):
# calls the method from the application class
self._init_from_design(
Expand Down
3 changes: 2 additions & 1 deletion pyaedt/desktop.py
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,8 @@ def __init__(
sys.path.append(
os.path.join(self._main.sDesktopinstallDirectory, "common", "commonfiles", "IronPython", "DLLs")
)

if "GetGrpcServerPort" in dir(self.odesktop):
self.port = self.odesktop.GetGrpcServerPort()
# save the current desktop session in the database
_desktop_sessions[self.aedt_process_id] = self

Expand Down
15 changes: 3 additions & 12 deletions pyaedt/modeler/cad/elements3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,11 +232,8 @@
except Exception as e:
return None

def __repr__(self):
return "Vertex " + str(self.id)

def __str__(self):
return "Vertex " + str(self.id)
return str(self.id)

Check warning on line 236 in pyaedt/modeler/cad/elements3d.py

View check run for this annotation

Codecov / codecov/patch

pyaedt/modeler/cad/elements3d.py#L236

Added line #L236 was not covered by tests


class EdgePrimitive(EdgeTypePrimitive, object):
Expand Down Expand Up @@ -366,11 +363,8 @@
except:
return False

def __repr__(self):
return "EdgeId " + str(self.id)

def __str__(self):
return "EdgeId " + str(self.id)
return str(self.id)

Check warning on line 367 in pyaedt/modeler/cad/elements3d.py

View check run for this annotation

Codecov / codecov/patch

pyaedt/modeler/cad/elements3d.py#L367

Added line #L367 was not covered by tests

@pyaedt_function_handler()
def create_object(self, non_model=False):
Expand Down Expand Up @@ -420,11 +414,8 @@
class FacePrimitive(object):
"""Contains the face object within the AEDT Desktop Modeler."""

def __repr__(self):
return "FaceId " + str(self.id)

def __str__(self):
return "FaceId " + str(self.id)
return str(self.id)

Check warning on line 418 in pyaedt/modeler/cad/elements3d.py

View check run for this annotation

Codecov / codecov/patch

pyaedt/modeler/cad/elements3d.py#L418

Added line #L418 was not covered by tests

def __init__(self, object3d, obj_id):
"""
Expand Down
8 changes: 1 addition & 7 deletions pyaedt/modeler/cad/object3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -1887,10 +1887,4 @@
return self._primitives._change_geometry_property(vPropChange, self._m_name)

def __str__(self):
return """
name: {} id: {} object_type: {}
""".format(
self.name,
self.id,
self._object_type,
)
return self.name

Check warning on line 1890 in pyaedt/modeler/cad/object3d.py

View check run for this annotation

Codecov / codecov/patch

pyaedt/modeler/cad/object3d.py#L1890

Added line #L1890 was not covered by tests
Loading