Skip to content

Commit 621f3ca

Browse files
committed
Replace get_violations_count with something a bit more straightforward
1 parent fe23099 commit 621f3ca

File tree

2 files changed

+9
-24
lines changed

2 files changed

+9
-24
lines changed

scripts/klayout/xml_drc_report_to_json.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
15-
1615
import json
1716

1817
from klayout.rdb import ReportDatabase
@@ -26,17 +25,18 @@ def cli(xml_file, json_file):
2625
database = ReportDatabase("Database")
2726
json_database = {}
2827
database.load(xml_file)
28+
total = 0
2929
for category in database.each_category():
3030
num_items = category.num_items()
3131
category_name = category.name()
3232
json_database[category_name] = num_items
33+
total += num_items
34+
35+
json_database = dict(sorted(json_database.items(), key=lambda item: item[1]))
36+
json_database["total"] = total
3337

34-
with open(json_file, "w") as f:
35-
f.write(
36-
json.dumps(
37-
dict(sorted(json_database.items(), key=lambda item: item[1])), indent=4
38-
)
39-
)
38+
with open(json_file, "w", encoding="utf8") as f:
39+
json.dump(json_database, f)
4040

4141

4242
if __name__ == "__main__":

scripts/tcl_commands/checkers.tcl

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -387,24 +387,9 @@ proc quit_on_unconnected_pdn_nodes {args} {
387387
}
388388
}
389389

390-
proc get_violations_count {report_file} {
391-
package require json
392-
393-
set total_violations_count 0
394-
395-
set fp [open $report_file r]
396-
set violations_json [read $fp]
397-
close $fp
398-
399-
set violations_dict [json::json2dict $violations_json]
400-
foreach count [dict values $violations_dict] {
401-
set total_violations_count [expr $total_violations_count + $count]
402-
}
403-
return $total_violations_count
404-
}
405-
406390
proc quit_on_klayout_drc {report_file} {
407-
set violations_count [get_violations_count $report_file]
391+
set violations_dict [json::json2dict [cat $report_file]]
392+
set violations_count [dict get $violations_dict "total"]
408393
if { $::env(QUIT_ON_KLAYOUT_DRC) && $violations_count != 0} {
409394
puts_err "There are violations in the design after KLayout DRC."
410395
puts_err "Total Number of violations is $violations_count"

0 commit comments

Comments
 (0)