This repository has been archived by the owner on Oct 2, 2020. It is now read-only.
/
F7_3.py
53 lines (39 loc) · 1.56 KB
/
F7_3.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# -*- coding: utf-8 -*-
from rules.rule import *
class Rule(KLCRule):
"""
Create the methods check and fix to use with the kicad_mod files.
"""
def __init__(self, module, args):
super(Rule, self).__init__(module, args, 'Pad 1 should be denoted by rectangular pad')
self.names = ['1', 'A', 'A1', 'P1', 'PAD1']
self.pad_1_shapes = ['rect', 'roundrect']
def check(self):
# Skip checks for non THT parts
if not self.module.attribute == 'pth':
return False
pad_1_rectangular = True
other_pads_rectangular = False
for pad in self.module.pads:
num = pad['number']
# Pin 1!
if str(num).upper() in self.names:
if not pad['shape'] in self.pad_1_shapes:
pad_1_rectangular = False
else:
if pad['shape'] in self.pad_1_shapes:
other_pads_rectangular = True
if not pad_1_rectangular and len(self.module.pads) >= 2:
self.warning("Pad 1 should be rectangular")
self.warningExtra("Ignore for non-polarized devices")
if other_pads_rectangular:
self.warning("Only pad 1 should be rectangular")
return False
def fix(self):
"""
Proceeds the fixing of the rule, if possible.
"""
module = self.module
for pad in module.filterPads('thru_hole'):
self.info("Pad {n} - Setting required layers for THT pad".format(n=pad['number']))
pad['layers'] = self.required_layers