Skip to content

Commit 93c385f

Browse files
committed
Merge remote-tracking branch 'origin/update_erl_to_relative_path' into update_erl_to_relative_path
2 parents 7c79de8 + 65b7973 commit 93c385f

File tree

4 files changed

+72
-233
lines changed

4 files changed

+72
-233
lines changed

doc/changelog.d/6024.miscellaneous.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pathlib refactor primitives_circuit.py

doc/changelog.d/6030.miscellaneous.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
move add calculation to CommonOptimetrics

src/ansys/aedt/core/modeler/circuits/primitives_circuit.py

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
# SOFTWARE.
2424

2525
import math
26-
import os
2726
from pathlib import Path
2827
import secrets
2928
import warnings
@@ -488,7 +487,7 @@ def create_model_from_touchstone(self, input_file, model_name=None, show_bitmap=
488487
489488
Parameters
490489
----------
491-
input_file : str
490+
input_file : str or :class:`pathlib.Path`
492491
Full path to the Touchstone file.
493492
model_name : str, optional
494493
Name of the model. The default is ``None``.
@@ -508,12 +507,12 @@ def create_model_from_touchstone(self, input_file, model_name=None, show_bitmap=
508507
"""
509508

510509
if not model_name:
511-
model_name = os.path.splitext(os.path.basename(input_file))[0]
510+
model_name = Path(Path(input_file).name).stem
512511
if "." in model_name:
513512
model_name = model_name.replace(".", "_")
514513
if model_name in list(self.omodel_manager.GetNames()):
515514
model_name = generate_unique_name(model_name, n=2)
516-
num_terminal = int(os.path.splitext(input_file)[1].lower().strip(".sp"))
515+
num_terminal = int(Path(input_file).suffix.lower().strip(".sp"))
517516

518517
port_names = []
519518
with open_file(input_file, "r") as f:
@@ -527,8 +526,8 @@ def create_model_from_touchstone(self, input_file, model_name=None, show_bitmap=
527526
image_subcircuit_path = ""
528527
bmp_file_name = ""
529528
if show_bitmap:
530-
image_subcircuit_path = os.path.join(self._app.desktop_install_dir, "syslib", "Bitmaps", "nport.bmp")
531-
bmp_file_name = os.path.basename(image_subcircuit_path)
529+
image_subcircuit_path = Path(self._app.desktop_install_dir) / "syslib" / "Bitmaps" / "nport.bmp"
530+
bmp_file_name = Path(image_subcircuit_path).name
532531

533532
if not port_names:
534533
port_names = ["Port" + str(i + 1) for i in range(num_terminal)]
@@ -547,13 +546,13 @@ def create_model_from_touchstone(self, input_file, model_name=None, show_bitmap=
547546
"Description:=",
548547
"",
549548
"ImageFile:=",
550-
image_subcircuit_path,
549+
str(image_subcircuit_path),
551550
"SymbolPinConfiguration:=",
552551
0,
553552
["NAME:PortInfoBlk"],
554553
["NAME:PortOrderBlk"],
555554
"filename:=",
556-
input_file,
555+
str(input_file),
557556
"numberofports:=",
558557
num_terminal,
559558
"sssfilename:=",
@@ -662,7 +661,7 @@ def create_model_from_touchstone(self, input_file, model_name=None, show_bitmap=
662661
"InfoHelpFile:=",
663662
"",
664663
"IconFile:=",
665-
bmp_file_name,
664+
str(bmp_file_name),
666665
"Library:=",
667666
"",
668667
"OriginalLocation:=",
@@ -765,7 +764,7 @@ def create_model_from_nexxim_state_space(self, input_file, num_terminal, model_n
765764
"""
766765

767766
if not model_name:
768-
model_name = os.path.splitext(os.path.basename(input_file))[0]
767+
model_name = Path(Path(input_file).name).stem
769768
if "." in model_name:
770769
model_name = model_name.replace(".", "_")
771770
if model_name in list(self.omodel_manager.GetNames()):
@@ -1681,18 +1680,18 @@ def __init__(self, component_manager):
16811680
def _index_components(self, library_path=None):
16821681
if library_path:
16831682
sys_files = recursive_glob(library_path, "*.aclb")
1684-
root = os.path.normpath(library_path).split(os.path.sep)[-1]
1683+
root = Path(library_path).name
16851684
else:
1686-
sys_files = recursive_glob(os.path.join(self._app.syslib, self._component_manager.design_libray), "*.aclb")
1687-
root = os.path.normpath(self._app.syslib).split(os.path.sep)[-1]
1685+
sys_files = recursive_glob(Path(self._app.syslib) / self._component_manager.design_libray, "*.aclb")
1686+
root = Path(self._app.syslib).name
16881687
for file in sys_files:
16891688
comps1 = load_keyword_in_aedt_file(file, "DefInfo")
16901689
comps2 = load_keyword_in_aedt_file(file, "CompInfo")
16911690
comps = comps1.get("DefInfo", {})
16921691
comps.update(comps2.get("CompInfo", {}))
16931692
for compname, comp_value in comps.items():
1694-
root_name, ext = os.path.splitext(os.path.normpath(file))
1695-
full_path = root_name.split(os.path.sep)
1693+
root_name = str(Path(file).with_suffix(""))
1694+
full_path = list(Path(root_name).parts)
16961695
id = full_path.index(root) + 1
16971696
if self._component_manager.design_libray in full_path[id:]:
16981697
id += 1

0 commit comments

Comments
 (0)