diff --git a/src/pyedb/dotnet/edb.py b/src/pyedb/dotnet/edb.py index 8873aea3c4..67a2e62c07 100644 --- a/src/pyedb/dotnet/edb.py +++ b/src/pyedb/dotnet/edb.py @@ -4735,3 +4735,37 @@ def get_variable_value(self, variable_name): return self.variables[variable_name] else: return False + + def compare(self, input_file, results=""): + """Compares current open database with another one. + + Parameters + ---------- + input_file : str + Path to the edb file. + results: str, optional + Path to directory in which results will be saved. If no path is given, a new "_compare_results" + directory will be created with the same naming and path as the .aedb folder. + Returns + ------- + bool + ``True`` when successful, ``False`` when failed. + """ + self.save() + if not results: + results = self.edbpath[:-5] + "_compare_results" + os.mkdir(results) + command = os.path.join(self.base_path, "EDBDiff.exe") + if is_linux: + mono_path = os.path.join(self.base_path, "common/mono/Linux64/bin/mono") + cmd_input = [mono_path, command, input_file, self.edbpath, results] + else: + cmd_input = [command, input_file, self.edbpath, results] + subprocess.run(cmd_input) + + if not os.path.exists(os.path.join(results, "EDBDiff.csv")): + self.logger.error("Comparison execution failed") + return False + else: + self.logger.info("Comparison correctly completed") + return True diff --git a/src/pyedb/grpc/edb.py b/src/pyedb/grpc/edb.py index 4ca5c18d56..6e801766e5 100644 --- a/src/pyedb/grpc/edb.py +++ b/src/pyedb/grpc/edb.py @@ -3800,3 +3800,37 @@ def export_gds_comp_xml(self, comps_to_export, gds_comps_unit="mm", control_path ET.indent(tree, space="\t", level=0) tree.write(control_path) return True if os.path.exists(control_path) else False + + def compare(self, input_file, results=""): + """Compares current open database with another one. + + Parameters + ---------- + input_file : str + Path to the edb file. + results: str, optional + Path to directory in which results will be saved. If no path is given, a new "_compare_results" + directory will be created with the same naming and path as the .aedb folder. + Returns + ------- + bool + ``True`` when successful, ``False`` when failed. + """ + self.save() + if not results: + results = self.edbpath[:-5] + "_compare_results" + os.mkdir(results) + command = os.path.join(self.base_path, "EDBDiff.exe") + if is_linux: + mono_path = os.path.join(self.base_path, "common/mono/Linux64/bin/mono") + cmd_input = [mono_path, command, input_file, self.edbpath, results] + else: + cmd_input = [command, input_file, self.edbpath, results] + subprocess.run(cmd_input) + + if not os.path.exists(os.path.join(results, "EDBDiff.csv")): + self.logger.error("Comparison execution failed") + return False + else: + self.logger.info("Comparison correctly completed") + return True diff --git a/tests/grpc/system/test_edb.py b/tests/grpc/system/test_edb.py index 79911b93f1..766427d2fe 100644 --- a/tests/grpc/system/test_edb.py +++ b/tests/grpc/system/test_edb.py @@ -1964,3 +1964,10 @@ def test_hfss_get_trace_width_for_traces_with_ports(self, edb_examples): trace_widths = edbapp.hfss.get_trace_width_for_traces_with_ports() assert len(trace_widths) > 0 edbapp.close() + + def test_compare_edbs(self, edb_examples): + edbapp = edb_examples.get_si_verse() + edb_base = os.path.join(local_path, "example_models", "TEDB", "ANSYS-HSD_V1.aedb") + assert edbapp.compare(edb_base) + folder = edbapp.edbpath[:-5] + "_compare_results" + assert os.path.exists(folder) diff --git a/tests/legacy/system/test_edb.py b/tests/legacy/system/test_edb.py index d76d19a7bb..8a462ffe6a 100644 --- a/tests/legacy/system/test_edb.py +++ b/tests/legacy/system/test_edb.py @@ -1987,3 +1987,10 @@ def test_hfss_get_trace_width_for_traces_with_ports(self, edb_examples): trace_widths = edbapp.hfss.get_trace_width_for_traces_with_ports() assert len(trace_widths) > 0 edbapp.close() + + def test_compare_edbs(self, edb_examples): + edbapp = edb_examples.get_si_verse() + edb_base = os.path.join(local_path, "example_models", "TEDB", "ANSYS-HSD_V1.aedb") + assert edbapp.compare(edb_base) + folder = edbapp.edbpath[:-5] + "_compare_results" + assert os.path.exists(folder)