Skip to content

Commit c6425b6

Browse files
REFACTOR: Pathlib hfss.py (#6054)
Co-authored-by: pyansys-ci-bot <[email protected]>
1 parent 979f6c2 commit c6425b6

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

doc/changelog.d/6054.miscellaneous.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Pathlib hfss.py

src/ansys/aedt/core/application/design.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3912,7 +3912,7 @@ def validate_simple(self, log_file=None):
39123912
39133913
Parameters
39143914
----------
3915-
log_file : str, optional
3915+
log_file : str or :class:`pathlib.Path`, optional
39163916
Name of the log file to save validation information to.
39173917
The default is ``None``.
39183918
@@ -3926,7 +3926,7 @@ def validate_simple(self, log_file=None):
39263926
>>> oDesign.ValidateDesign
39273927
"""
39283928
if log_file:
3929-
return self._odesign.ValidateDesign(log_file)
3929+
return self._odesign.ValidateDesign(str(log_file))
39303930
else:
39313931
return self._odesign.ValidateDesign()
39323932

src/ansys/aedt/core/hfss.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626

2727
import ast
2828
import math
29-
import os
3029
from pathlib import Path
3130
import tempfile
3231
from typing import Union
@@ -2681,7 +2680,7 @@ def create_sbr_linked_antenna(
26812680
if assignment.project_name == self.project_name:
26822681
project_name = "This Project*"
26832682
else:
2684-
project_name = os.path.join(assignment.project_path, assignment.project_name + ".aedt")
2683+
project_name = Path(assignment.project_path) / (assignment.project_name + ".aedt")
26852684
design_name = assignment.design_name
26862685
if not setup:
26872686
setup = assignment.nominal_adaptive
@@ -2696,7 +2695,7 @@ def create_sbr_linked_antenna(
26962695
"Unit": self.modeler.model_units,
26972696
"Version": 0,
26982697
"Is Parametric Array": False,
2699-
"Project": project_name,
2698+
"Project": str(project_name),
27002699
"Product": "HFSS",
27012700
"Design": design_name,
27022701
"Soln": setup,
@@ -2812,7 +2811,7 @@ def create_sbr_custom_array_file(
28122811
>>> hfss.release_desktop()
28132812
"""
28142813
if output_file is None:
2815-
output_file = os.path.join(self.working_directory, "custom_array.sarr")
2814+
output_file = Path(self.working_directory) / "custom_array.sarr"
28162815

28172816
if frequencies is None:
28182817
frequencies = [1.0]
@@ -4829,7 +4828,7 @@ def validate_full_design(self, design=None, output_dir=None, ports=None):
48294828
if not output_dir:
48304829
output_dir = self.working_directory
48314830
pname = self.project_name
4832-
validation_log_file = os.path.join(output_dir, pname + "_" + design + "_validation.log")
4831+
validation_log_file = Path(output_dir) / (pname + "_" + design + "_validation.log")
48334832

48344833
# Desktop Messages
48354834
msg = "Desktop messages:"
@@ -4841,7 +4840,7 @@ def validate_full_design(self, design=None, output_dir=None, ports=None):
48414840

48424841
# Run design validation and write out the lines to the log.
48434842
temp_dir = tempfile.gettempdir()
4844-
temp_val_file = os.path.join(temp_dir, "val_temp.log")
4843+
temp_val_file = Path(temp_dir) / "val_temp.log"
48454844
simple_val_return = self.validate_simple(temp_val_file)
48464845
if simple_val_return == 1:
48474846
msg = "Design validation check PASSED."
@@ -4851,11 +4850,11 @@ def validate_full_design(self, design=None, output_dir=None, ports=None):
48514850
val_list.append(msg)
48524851
msg = "Design validation messages:"
48534852
val_list.append(msg)
4854-
if os.path.isfile(temp_val_file) or settings.remote_rpc_session:
4853+
if temp_val_file.is_file() or settings.remote_rpc_session:
48554854
with open_file(temp_val_file, "r") as df:
48564855
temp = df.read().splitlines()
48574856
val_list.extend(temp)
4858-
os.remove(temp_val_file)
4857+
temp_val_file.unlink()
48594858
else:
48604859
msg = "** No design validation file is found. **"
48614860
self.logger.info(msg)
@@ -6626,7 +6625,7 @@ def parse_hdm_file(self, file_name):
66266625
66276626
Parameters
66286627
----------
6629-
file_name : str
6628+
file_name : str or :class:`pathlib.Path`
66306629
Name of the file to parse.
66316630
66326631
Returns
@@ -6636,8 +6635,8 @@ def parse_hdm_file(self, file_name):
66366635

66376636
from ansys.aedt.core.visualization.advanced.sbrplus.hdm_parser import Parser
66386637

6639-
if os.path.exists(file_name):
6640-
return Parser(file_name).parse_message()
6638+
if Path(file_name).exists():
6639+
return Parser(str(file_name)).parse_message()
66416640
return False
66426641

66436642
@pyaedt_function_handler(filename="file_name")
@@ -7484,7 +7483,7 @@ def export_element_pattern(
74847483
variation = self.available_variations.variation_string(variations)
74857484
command = [
74867485
"ExportFileName:=",
7487-
os.path.join(output_dir, element_name + ".ffd"),
7486+
str(Path(output_dir) / (element_name + ".ffd")),
74887487
"SetupName:=",
74897488
sphere,
74907489
]

0 commit comments

Comments
 (0)