55import pya
66import json
77
8+
89def convert_drc (rdb ):
910 source = os .path .abspath (in_drc )
1011
11- ordb = {
12- "source" : source ,
13- "description" : "KLayout DRC conversion" ,
14- "category" : {}
15- }
12+ ordb = {"source" : source , "description" : "KLayout DRC conversion" , "category" : {}}
1613
1714 for category in rdb .each_category ():
1815 if category .num_items () == 0 :
@@ -22,15 +19,15 @@ def convert_drc(rdb):
2219 ordb_category = {
2320 "description" : category .description ,
2421 "source" : source ,
25- "violations" : []
22+ "violations" : [],
2623 }
2724 ordb ["category" ][category .name ()] = ordb_category
2825
2926 for item in rdb .each_item_per_category (category .rdb_id ()):
3027 violation = {
3128 "visited" : item .is_visited (),
3229 "visible" : True ,
33- "waived" : "waived" in item .tags_str
30+ "waived" : "waived" in item .tags_str ,
3431 }
3532
3633 ordb_category ["violations" ].append (violation )
@@ -42,81 +39,59 @@ def convert_drc(rdb):
4239
4340 for value in item .each_value ():
4441 if value .is_box ():
45- shapes .append ({
46- "type" : "box" ,
47- "points" : [{
48- "x" : value .box ().left ,
49- "y" : value .box ().bottom
50- }, {
51- "x" : value .box ().right ,
52- "y" : value .box ().top
53- }]
54- })
42+ shapes .append (
43+ {
44+ "type" : "box" ,
45+ "points" : [
46+ {"x" : value .box ().left , "y" : value .box ().bottom },
47+ {"x" : value .box ().right , "y" : value .box ().top },
48+ ],
49+ }
50+ )
5551 elif value .is_edge ():
56- shapes .append ({
57- "type" : "line" ,
58- "points" : [{
59- "x" : value .edge ().p1 .x ,
60- "y" : value .edge ().p1 .y
61- }, {
62- "x" : value .edge ().p2 .x ,
63- "y" : value .edge ().p2 .y
64- }]
65- })
52+ shapes .append (
53+ {
54+ "type" : "line" ,
55+ "points" : [
56+ {"x" : value .edge ().p1 .x , "y" : value .edge ().p1 .y },
57+ {"x" : value .edge ().p2 .x , "y" : value .edge ().p2 .y },
58+ ],
59+ }
60+ )
6661 elif value .is_edge_pair ():
6762 edge1 = value .edge_pair ().first
6863 edge2 = value .edge_pair ().second
6964
70- shapes .append ({
71- "type" : "line" ,
72- "points" : [{
73- "x" : edge1 .p1 .x ,
74- "y" : edge1 .p1 .y
75- }, {
76- "x" : edge1 .p2 .x ,
77- "y" : edge1 .p2 .y
78- }]
79- })
80- shapes .append ({
81- "type" : "line" ,
82- "points" : [{
83- "x" : edge2 .p1 .x ,
84- "y" : edge2 .p1 .y
85- }, {
86- "x" : edge2 .p2 .x ,
87- "y" : edge2 .p2 .y
88- }]
89- })
65+ shapes .append (
66+ {
67+ "type" : "line" ,
68+ "points" : [
69+ {"x" : edge1 .p1 .x , "y" : edge1 .p1 .y },
70+ {"x" : edge1 .p2 .x , "y" : edge1 .p2 .y },
71+ ],
72+ }
73+ )
74+ shapes .append (
75+ {
76+ "type" : "line" ,
77+ "points" : [
78+ {"x" : edge2 .p1 .x , "y" : edge2 .p1 .y },
79+ {"x" : edge2 .p2 .x , "y" : edge2 .p2 .y },
80+ ],
81+ }
82+ )
9083 elif value .is_polygon ():
9184 points = []
9285 for edge in value .polygon ().each_edge ():
93- points .append ({
94- "x" : edge .p1 .x ,
95- "y" : edge .p1 .y
96- })
97- points .append ({
98- "x" : edge .p2 .x ,
99- "y" : edge .p2 .y
100- })
101- shapes .append ({
102- "type" : "polygon" ,
103- "points" : points
104- })
86+ points .append ({"x" : edge .p1 .x , "y" : edge .p1 .y })
87+ points .append ({"x" : edge .p2 .x , "y" : edge .p2 .y })
88+ shapes .append ({"type" : "polygon" , "points" : points })
10589 elif value .is_path ():
10690 points = []
10791 for edge in value .path ().polygon ().each_edge ():
108- points .append ({
109- "x" : edge .p1 .x ,
110- "y" : edge .p1 .y
111- })
112- points .append ({
113- "x" : edge .p2 .x ,
114- "y" : edge .p2 .y
115- })
116- shapes .append ({
117- "type" : "polygon" ,
118- "points" : points
119- })
92+ points .append ({"x" : edge .p1 .x , "y" : edge .p1 .y })
93+ points .append ({"x" : edge .p2 .x , "y" : edge .p2 .y })
94+ shapes .append ({"type" : "polygon" , "points" : points })
12095 elif value .is_text ():
12196 text .append (value .text ())
12297 elif value .is_string ():
@@ -125,7 +100,7 @@ def convert_drc(rdb):
125100 print ("[WARN] Unknown violation shape:" , value )
126101
127102 comment = ""
128- if hasattr (item , ' comment' ):
103+ if hasattr (item , " comment" ):
129104 comment = item .comment
130105 if text :
131106 if comment :
@@ -137,6 +112,7 @@ def convert_drc(rdb):
137112
138113 return ordb
139114
115+
140116app = pya .Application .instance ()
141117win = app .main_window ()
142118
0 commit comments