Skip to content

Commit

Permalink
Merge pull request #2562 from The-OpenROAD-Project-staging/format-con…
Browse files Browse the repository at this point in the history
…vertDrc

Format util/convertDrc.py with black
  • Loading branch information
maliberty authored Nov 14, 2024
2 parents bf819ca + e1f63d6 commit 9a1ccb4
Showing 1 changed file with 48 additions and 72 deletions.
120 changes: 48 additions & 72 deletions flow/util/convertDrc.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,11 @@
import pya
import json


def convert_drc(rdb):
source = os.path.abspath(in_drc)

ordb = {
"source": source,
"description": "KLayout DRC conversion",
"category": {}
}
ordb = {"source": source, "description": "KLayout DRC conversion", "category": {}}

for category in rdb.each_category():
if category.num_items() == 0:
Expand All @@ -22,15 +19,15 @@ def convert_drc(rdb):
ordb_category = {
"description": category.description,
"source": source,
"violations": []
"violations": [],
}
ordb["category"][category.name()] = ordb_category

for item in rdb.each_item_per_category(category.rdb_id()):
violation = {
"visited": item.is_visited(),
"visible": True,
"waived": "waived" in item.tags_str
"waived": "waived" in item.tags_str,
}

ordb_category["violations"].append(violation)
Expand All @@ -42,81 +39,59 @@ def convert_drc(rdb):

for value in item.each_value():
if value.is_box():
shapes.append({
"type": "box",
"points": [{
"x": value.box().left,
"y": value.box().bottom
}, {
"x": value.box().right,
"y": value.box().top
}]
})
shapes.append(
{
"type": "box",
"points": [
{"x": value.box().left, "y": value.box().bottom},
{"x": value.box().right, "y": value.box().top},
],
}
)
elif value.is_edge():
shapes.append({
"type": "line",
"points": [{
"x": value.edge().p1.x,
"y": value.edge().p1.y
}, {
"x": value.edge().p2.x,
"y": value.edge().p2.y
}]
})
shapes.append(
{
"type": "line",
"points": [
{"x": value.edge().p1.x, "y": value.edge().p1.y},
{"x": value.edge().p2.x, "y": value.edge().p2.y},
],
}
)
elif value.is_edge_pair():
edge1 = value.edge_pair().first
edge2 = value.edge_pair().second

shapes.append({
"type": "line",
"points": [{
"x": edge1.p1.x,
"y": edge1.p1.y
}, {
"x": edge1.p2.x,
"y": edge1.p2.y
}]
})
shapes.append({
"type": "line",
"points": [{
"x": edge2.p1.x,
"y": edge2.p1.y
}, {
"x": edge2.p2.x,
"y": edge2.p2.y
}]
})
shapes.append(
{
"type": "line",
"points": [
{"x": edge1.p1.x, "y": edge1.p1.y},
{"x": edge1.p2.x, "y": edge1.p2.y},
],
}
)
shapes.append(
{
"type": "line",
"points": [
{"x": edge2.p1.x, "y": edge2.p1.y},
{"x": edge2.p2.x, "y": edge2.p2.y},
],
}
)
elif value.is_polygon():
points = []
for edge in value.polygon().each_edge():
points.append({
"x": edge.p1.x,
"y": edge.p1.y
})
points.append({
"x": edge.p2.x,
"y": edge.p2.y
})
shapes.append({
"type": "polygon",
"points": points
})
points.append({"x": edge.p1.x, "y": edge.p1.y})
points.append({"x": edge.p2.x, "y": edge.p2.y})
shapes.append({"type": "polygon", "points": points})
elif value.is_path():
points = []
for edge in value.path().polygon().each_edge():
points.append({
"x": edge.p1.x,
"y": edge.p1.y
})
points.append({
"x": edge.p2.x,
"y": edge.p2.y
})
shapes.append({
"type": "polygon",
"points": points
})
points.append({"x": edge.p1.x, "y": edge.p1.y})
points.append({"x": edge.p2.x, "y": edge.p2.y})
shapes.append({"type": "polygon", "points": points})
elif value.is_text():
text.append(value.text())
elif value.is_string():
Expand All @@ -125,7 +100,7 @@ def convert_drc(rdb):
print("[WARN] Unknown violation shape:", value)

comment = ""
if hasattr(item, 'comment'):
if hasattr(item, "comment"):
comment = item.comment
if text:
if comment:
Expand All @@ -137,6 +112,7 @@ def convert_drc(rdb):

return ordb


app = pya.Application.instance()
win = app.main_window()

Expand Down

0 comments on commit 9a1ccb4

Please sign in to comment.