Skip to content

Commit

Permalink
add missing script
Browse files Browse the repository at this point in the history
  • Loading branch information
kareefardi committed Dec 6, 2023
1 parent cd8ac24 commit 6f470af
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions scripts/klayout/xml_drc_report_to_json.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env python3
# Copyright (c) 2023 Efabless Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import json

from klayout.rdb import ReportDatabase
import click


@click.command()
@click.option("--xml-file")
@click.option("--json-file")
def cli(xml_file, json_file):
database = ReportDatabase("Database")
json_database = {}
database.load(xml_file)
for category in database.each_category():
num_items = category.num_items()
category_name = category.name()
json_database[category_name] = num_items

with open(json_file, "w") as f:
f.write(
json.dumps(
dict(sorted(json_database.items(), key=lambda item: item[1])), indent=4
)
)


if __name__ == "__main__":
cli()

0 comments on commit 6f470af

Please sign in to comment.