diff --git a/common/rulebase.py b/common/rulebase.py index 6ebb194b..12edf878 100644 --- a/common/rulebase.py +++ b/common/rulebase.py @@ -91,8 +91,8 @@ def name(self): path = "".join(path.split(".")[:-1]) return path.replace('_', '.') - def __init__(self, description): - self.description = description + def __init__(self): + self.description = self.__doc__.strip().splitlines()[0].strip() self.messageBuffer=[] self.resetErrorCount() self.resetWarningCount() diff --git a/pcb/rules/F5_1.py b/pcb/rules/F5_1.py index a162c9b0..bc267851 100644 --- a/pcb/rules/F5_1.py +++ b/pcb/rules/F5_1.py @@ -7,11 +7,7 @@ import cmath 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, "Silkscreen layer requirements") + """Silkscreen layer requirements""" def checkReference(self): """ diff --git a/pcb/rules/F5_2.py b/pcb/rules/F5_2.py index da37094f..8daa82a5 100644 --- a/pcb/rules/F5_2.py +++ b/pcb/rules/F5_2.py @@ -10,11 +10,7 @@ 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, "Fabrication layer requirements") + """Fabrication layer requirements""" # Check for presence of component value def checkMissingValue(self): diff --git a/pcb/rules/F5_3.py b/pcb/rules/F5_3.py index 2f9e785b..7aa448b3 100644 --- a/pcb/rules/F5_3.py +++ b/pcb/rules/F5_3.py @@ -16,11 +16,7 @@ from boundingbox import BoundingBox 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, "Courtyard layer requirements") + """Courtyard layer requirements""" # Get the superposed boundary of pads and fab layer def getFootprintBounds(self): @@ -214,4 +210,4 @@ def fix(self): self.module.addRectangle( [cy['x'], cy['y']], [cy['x'] + cy['width'], cy['y'] + cy['height']], - 'F.CrtYd', KLC_CRTYD_WIDTH) \ No newline at end of file + 'F.CrtYd', KLC_CRTYD_WIDTH) diff --git a/pcb/rules/F6_1.py b/pcb/rules/F6_1.py index 8ae77968..ce00ad97 100644 --- a/pcb/rules/F6_1.py +++ b/pcb/rules/F6_1.py @@ -5,11 +5,7 @@ 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, 'For surface-mount devices, placement type must be set to "Surface Mount"') + """Footprint placement type must be set to surface mount""" def check(self): """ diff --git a/pcb/rules/F6_2.py b/pcb/rules/F6_2.py index 7223f02e..2c4e7150 100644 --- a/pcb/rules/F6_2.py +++ b/pcb/rules/F6_2.py @@ -5,11 +5,7 @@ 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,'For surface-mount devices, footprint anchor is placed in the middle of the footprint (IPC-7351).') + """Footprint anchor should be placed in the middle of the component body""" def check(self): """ diff --git a/pcb/rules/F6_3.py b/pcb/rules/F6_3.py index ce939fb2..4e068fe6 100644 --- a/pcb/rules/F6_3.py +++ b/pcb/rules/F6_3.py @@ -3,11 +3,10 @@ from rules.rule import * class Rule(KLCRule): - """ - Create the methods check and fix to use with the kicad_mod files. - """ + """Pad requirements for SMD footprints""" + def __init__(self, module, args): - super(Rule, self).__init__(module, args, 'Pad requirements for SMD footprints') + super(Rule, self).__init__(module, args) self.required_layers = ["Cu", "Paste", "Mask"] self.sides = ["F.", "B."] diff --git a/pcb/rules/F7_1.py b/pcb/rules/F7_1.py index 6686a7d8..290ecf99 100644 --- a/pcb/rules/F7_1.py +++ b/pcb/rules/F7_1.py @@ -5,11 +5,7 @@ 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, 'For through-hole devices, placement type must be set to "Through Hole"') + """Footprint placement type must be set to Through Hole""" def check(self): """ diff --git a/pcb/rules/F7_2.py b/pcb/rules/F7_2.py index 04e9401d..8ae55035 100644 --- a/pcb/rules/F7_2.py +++ b/pcb/rules/F7_2.py @@ -3,11 +3,10 @@ from rules.rule import * class Rule(KLCRule): - """ - Create the methods check and fix to use with the kicad_mod files. - """ + """Footprint anchor should placed at the location of Pin-1""" + def __init__(self, module, args): - super(Rule, self).__init__(module, args, 'For through-hole components, footprint anchor is set on pad 1') + super(Rule, self).__init__(module, args) self.pin1_position = [] self.pin1_count = 0 diff --git a/pcb/rules/F7_3.py b/pcb/rules/F7_3.py index 5a8fc5d8..b5bd8294 100644 --- a/pcb/rules/F7_3.py +++ b/pcb/rules/F7_3.py @@ -3,11 +3,10 @@ from rules.rule import * class Rule(KLCRule): - """ - Create the methods check and fix to use with the kicad_mod files. - """ + """Pin 1 should be rectangular, and other pads circular or oval""" + def __init__(self, module, args): - super(Rule, self).__init__(module, args, 'Pad 1 should be denoted by rectangular pad') + super(Rule, self).__init__(module, args) self.names = ['1', 'A', 'A1', 'P1', 'PAD1'] self.pad_1_shapes = ['rect', 'roundrect'] diff --git a/pcb/rules/F7_4.py b/pcb/rules/F7_4.py index 137af6cb..225167bf 100644 --- a/pcb/rules/F7_4.py +++ b/pcb/rules/F7_4.py @@ -3,11 +3,10 @@ from rules.rule import * class Rule(KLCRule): - """ - Create the methods check and fix to use with the kicad_mod files. - """ + """Pad requirements for THT footprints""" + def __init__(self, module, args): - super(Rule, self).__init__(module, args, 'Pad requirements for THT footprints') + super(Rule, self).__init__(module, args) self.required_layers = ["*.Cu","*.Mask"] diff --git a/pcb/rules/F7_5.py b/pcb/rules/F7_5.py index 2a3549a8..165d0ff7 100644 --- a/pcb/rules/F7_5.py +++ b/pcb/rules/F7_5.py @@ -5,11 +5,7 @@ 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, 'Annular ring must be at least 0.15mm') + """Minimum annular ring width""" def checkPad(self, pad): if not 'size' in pad['drill']: diff --git a/pcb/rules/F7_6.py b/pcb/rules/F7_6.py index ea90735b..89de0537 100644 --- a/pcb/rules/F7_6.py +++ b/pcb/rules/F7_6.py @@ -3,11 +3,7 @@ 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, 'Minimum hole drill size') + """Minimum hole diameter""" def checkPad(self, pad): diff --git a/pcb/rules/F9_1.py b/pcb/rules/F9_1.py index 2477e207..2ad4486a 100644 --- a/pcb/rules/F9_1.py +++ b/pcb/rules/F9_1.py @@ -4,11 +4,7 @@ import os 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, 'Footprint metadata must be filled as appropriate') + """Footprint meta-data is filled in as appropriate""" def checkDocs(self): mod = self.module diff --git a/pcb/rules/F9_2.py b/pcb/rules/F9_2.py index 32757726..27b09383 100644 --- a/pcb/rules/F9_2.py +++ b/pcb/rules/F9_2.py @@ -3,11 +3,7 @@ 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, 'Footprint properties should be left to default values.') + """Footprint properties are as default values unless otherwise required in datasheet""" def check(self): """ diff --git a/pcb/rules/F9_3.py b/pcb/rules/F9_3.py index 613eefaf..69c6c651 100644 --- a/pcb/rules/F9_3.py +++ b/pcb/rules/F9_3.py @@ -7,9 +7,7 @@ SYSMOD_PREFIX = "${KISYS3DMOD}/" class Rule(KLCRule): - """ - Create the methods check and fix to use with the kicad_mod files. - """ + """Footprint 3D model requirements""" # Regular expression for suffixes that shouldn't be in the model file suffix_re = ( @@ -21,9 +19,6 @@ class Rule(KLCRule): ')' ) - def __init__(self, module, args): - super(Rule, self).__init__(module, args, '3D model settings') - def checkModel(self, model): error = False diff --git a/pcb/rules/G1_1.py b/pcb/rules/G1_1.py index c564e35d..7dafec07 100644 --- a/pcb/rules/G1_1.py +++ b/pcb/rules/G1_1.py @@ -4,11 +4,10 @@ import re class Rule(KLCRule): - """ - Create the methods check and fix to use with the kicad lib files. - """ + """Only standard characters are used for naming libraries and components""" + def __init__(self, module, args): - super(Rule, self).__init__(module, args, 'Illegal characters in footprint name') + super(Rule, self).__init__(module, args) # Set of allowed chars. Some characters need to be escaped. allowed_chars = "a-zA-Z0-9_\-\.,\+" self.pattern = re.compile('^['+allowed_chars+']+$') diff --git a/pcb/rules/G1_7.py b/pcb/rules/G1_7.py index 018f18d5..f94d3eff 100644 --- a/pcb/rules/G1_7.py +++ b/pcb/rules/G1_7.py @@ -4,11 +4,7 @@ import platform class Rule(KLCRule): - """ - Create the methods check and fix to use with the kicad lib files. - """ - def __init__(self, module, args): - super(Rule, self).__init__(module, args, 'Library files must use Unix-style line endings (LF)') + """Library files use Unix style line endings""" def check(self): diff --git a/pcb/rules/rule.py b/pcb/rules/rule.py index fc9b5119..4459632f 100644 --- a/pcb/rules/rule.py +++ b/pcb/rules/rule.py @@ -78,12 +78,13 @@ def graphItemString(graph, layer=False, width=False): return shapeText + layerText + widthText class KLCRule(KLCRuleBase): + """A base class to represent a KLC rule + + Create the methods check and fix to use with the kicad_mod files. """ - A base class to represent a KLC rule - """ - def __init__(self, module, args, description): + def __init__(self, module, args): - KLCRuleBase.__init__(self, description) + KLCRuleBase.__init__(self) self.module = module self.args = args @@ -99,4 +100,4 @@ def fix(self): def fixmore(self): if self.needsFixMore: self.info("fixmore not supported") - return \ No newline at end of file + return diff --git a/schlib/rules/EC01.py b/schlib/rules/EC01.py index 6b86b96b..dbdba93b 100644 --- a/schlib/rules/EC01.py +++ b/schlib/rules/EC01.py @@ -4,11 +4,7 @@ import re class Rule(KLCRule): - """ - Create the methods check and fix to use with the kicad lib files. - """ - def __init__(self, component): - super(Rule, self).__init__(component, 'General pin number checking') + """General pin number checking""" def checkPinNames(self): self.wrong_pin_numbers = [] diff --git a/schlib/rules/EC02.py b/schlib/rules/EC02.py index 808dd575..9f8c46e6 100644 --- a/schlib/rules/EC02.py +++ b/schlib/rules/EC02.py @@ -3,11 +3,7 @@ from rules.rule import * class Rule(KLCRule): - """ - Create the methods check and fix to use with the kicad lib files. - """ - def __init__(self, component): - super(Rule, self).__init__(component, 'Check part reference, name and footprint position and alignment') + """Check part reference, name and footprint position and alignment""" def check(self): """ diff --git a/schlib/rules/G1_1.py b/schlib/rules/G1_1.py index bdabbd66..28cb2568 100644 --- a/schlib/rules/G1_1.py +++ b/schlib/rules/G1_1.py @@ -4,11 +4,7 @@ import string class Rule(KLCRule): - """ - Create the methods check and fix to use with the kicad lib files. - """ - def __init__(self, component): - super(Rule, self).__init__(component, 'Illegal characters in symbol name') + """Only standard characters are used for naming libraries and components""" def check(self): diff --git a/schlib/rules/S3_1.py b/schlib/rules/S3_1.py index bcac9321..90a1f946 100644 --- a/schlib/rules/S3_1.py +++ b/schlib/rules/S3_1.py @@ -4,11 +4,7 @@ import math class Rule(KLCRule): - """ - Create the methods check and fix to use with the kicad lib files. - """ - def __init__(self, component): - super(Rule, self).__init__(component, 'Origin is centered on the middle of the symbol') + """Origin is centered on the middle of the symbol""" def check(self): """ diff --git a/schlib/rules/S3_2.py b/schlib/rules/S3_2.py index 18cbce6a..96af0912 100644 --- a/schlib/rules/S3_2.py +++ b/schlib/rules/S3_2.py @@ -3,11 +3,7 @@ from rules.rule import * class Rule(KLCRule): - """ - Create the methods check and fix to use with the kicad lib files. - """ - def __init__(self, component): - super(Rule, self).__init__(component, 'Text fields should use common size of 50mils, but labels and numbers may use text size as low as 20mil if required') + """Text fields should use a common text size of 50mils""" def check(self): """ diff --git a/schlib/rules/S3_3.py b/schlib/rules/S3_3.py index 6b0802ad..675e15c2 100644 --- a/schlib/rules/S3_3.py +++ b/schlib/rules/S3_3.py @@ -3,11 +3,7 @@ from rules.rule import * class Rule(KLCRule): - """ - Create the methods check and fix to use with the kicad lib files. - """ - def __init__(self, component): - super(Rule, self).__init__(component, 'Symbol outline and fill requirements') + """Symbol outline and fill requirements""" def check(self): """ diff --git a/schlib/rules/S3_6.py b/schlib/rules/S3_6.py index f6db994a..785046ea 100644 --- a/schlib/rules/S3_6.py +++ b/schlib/rules/S3_6.py @@ -3,11 +3,7 @@ from rules.rule import * class Rule(KLCRule): - """ - Create the methods check and fix to use with the kicad lib files. - """ - def __init__(self, component): - super(Rule, self).__init__(component, 'Pin name position offset') + """Pin name position offset""" def check(self): diff --git a/schlib/rules/S4_1.py b/schlib/rules/S4_1.py index f7091c64..e372ebe9 100644 --- a/schlib/rules/S4_1.py +++ b/schlib/rules/S4_1.py @@ -3,11 +3,7 @@ from rules.rule import * class Rule(KLCRule): - """ - Create the methods check and fix to use with the kicad lib files. - """ - def __init__(self, component): - super(Rule, self).__init__(component, 'Pin requirements') + """General pin requirements""" def checkPinOrigin(self, gridspacing=100): self.violating_pins = [] @@ -131,4 +127,4 @@ def fix(self): pass if self.checkPinLength(): - pass \ No newline at end of file + pass diff --git a/schlib/rules/S4_2.py b/schlib/rules/S4_2.py index d6973ebf..e996f9ff 100644 --- a/schlib/rules/S4_2.py +++ b/schlib/rules/S4_2.py @@ -4,11 +4,7 @@ import re class Rule(KLCRule): - """ - Create the methods check and fix to use with the kicad lib files. - """ - def __init__(self, component): - super(Rule, self).__init__(component, 'Pins should be arranged by function') + """Pins should be grouped by function""" def checkGroundPins(self): diff --git a/schlib/rules/S4_3.py b/schlib/rules/S4_3.py index ba41f859..07b38171 100644 --- a/schlib/rules/S4_3.py +++ b/schlib/rules/S4_3.py @@ -3,11 +3,10 @@ from rules.rule import * class Rule(KLCRule): - """ - Create the methods check and fix to use with the kicad lib files. - """ + """Rules for pin stacking""" + def __init__(self, component): - super(Rule, self).__init__(component, 'Rules for pin stacking') + super(Rule, self).__init__(component) self.different_names=False self.NC_stacked=False self.different_types=False diff --git a/schlib/rules/S4_4.py b/schlib/rules/S4_4.py index cfe37fd2..21d6cfa8 100644 --- a/schlib/rules/S4_4.py +++ b/schlib/rules/S4_4.py @@ -4,6 +4,7 @@ import re class Rule(KLCRule): + """Pin electrical type""" #Power Input Pins should be 'W' POWER_INPUTS = ['^[ad]*g(rou)*nd$', '^[ad]*v(aa|cc|dd|ss|bat|in)$'] @@ -39,12 +40,6 @@ def test(self, pinName, nameList): return False - """ - Create the methods check and fix to use with the kicad lib files. - """ - def __init__(self, component): - super(Rule, self).__init__(component, 'Pin electrical type should match pin function') - # These pin types must be satisfied def checkPowerPins(self, pins): diff --git a/schlib/rules/S4_6.py b/schlib/rules/S4_6.py index 8b2558f3..052d064a 100644 --- a/schlib/rules/S4_6.py +++ b/schlib/rules/S4_6.py @@ -4,6 +4,7 @@ import re class Rule(KLCRule): + """Hidden pins""" #No-connect pins should be "N" NC_PINS = ['^nc$', '^dnc$', '^n\.c\.$'] @@ -17,12 +18,6 @@ def test(self, pinName, nameList): return False - """ - Create the methods check and fix to use with the kicad lib files. - """ - def __init__(self, component): - super(Rule, self).__init__(component, 'Unused pins should be set as NOT CONNECTED and should be INVISIBLE') - def checkNCPins(self, pins): self.invisible_errors = [] diff --git a/schlib/rules/S5_1.py b/schlib/rules/S5_1.py index 8d78173c..80d2c177 100644 --- a/schlib/rules/S5_1.py +++ b/schlib/rules/S5_1.py @@ -4,11 +4,7 @@ import fnmatch class Rule(KLCRule): - """ - Create the methods check and fix to use with the kicad lib files. - """ - def __init__(self, component): - super(Rule, self).__init__(component, 'For components with a single default footprint, footprint field is filled with valid footprint filename') + """Symbols with a default footprint link to a valid footprint file""" def check(self): """ diff --git a/schlib/rules/S5_2.py b/schlib/rules/S5_2.py index 8c0a089d..6918356a 100644 --- a/schlib/rules/S5_2.py +++ b/schlib/rules/S5_2.py @@ -4,11 +4,7 @@ import re class Rule(KLCRule): - """ - Create the methods check and fix to use with the kicad lib files. - """ - def __init__(self, component): - super(Rule, self).__init__(component, 'Footprint filters should match all appropriate footprints') + """Footprint filters should match all appropriate footprints""" def checkFilters(self, filters): diff --git a/schlib/rules/S6_2.py b/schlib/rules/S6_2.py index 1bca9615..61c9ebb1 100644 --- a/schlib/rules/S6_2.py +++ b/schlib/rules/S6_2.py @@ -3,11 +3,7 @@ from rules.rule import * class Rule(KLCRule): - """ - Create the methods check and fix to use with the kicad lib files. - """ - def __init__(self, component): - super(Rule, self).__init__(component, 'Component fields contain the correct information') + """Component fields must be filled appropriately""" def checkVisibility(self, field): return field['visibility'] == 'V' diff --git a/schlib/rules/S6_3.py b/schlib/rules/S6_3.py index 1434a094..0ded03bd 100644 --- a/schlib/rules/S6_3.py +++ b/schlib/rules/S6_3.py @@ -3,11 +3,7 @@ from rules.rule import * class Rule(KLCRule): - """ - Create the methods check and fix to use with the kicad lib files. - """ - def __init__(self, component): - super(Rule, self).__init__(component, 'Part meta-data is filled in as appropriate') + """Component metadata is added to symbol (and all aliases)""" def check(self): """ diff --git a/schlib/rules/S7_1.py b/schlib/rules/S7_1.py index a15faca6..9e9b0ca0 100644 --- a/schlib/rules/S7_1.py +++ b/schlib/rules/S7_1.py @@ -4,11 +4,10 @@ import re class Rule(KLCRule): - """ - Create the methods check and fix to use with the kicad lib files. - """ + """Power flag symbols""" + def __init__(self, component): - super(Rule, self).__init__(component, 'Power-flag symbols follow some special rules/KLC-exceptions') + super(Rule, self).__init__(component) self.makePinINVISIBLE=False self.makePinPowerInput=False self.fixTooManyPins=False diff --git a/schlib/rules/S7_2.py b/schlib/rules/S7_2.py index 93244a62..73952acb 100644 --- a/schlib/rules/S7_2.py +++ b/schlib/rules/S7_2.py @@ -4,11 +4,10 @@ import re class Rule(KLCRule): - """ - Create the methods check and fix to use with the kicad lib files. - """ + """Graphical symbols""" + def __init__(self, component): - super(Rule, self).__init__(component, 'Graphical symbols follow some special rules/KLC-exceptions') + super(Rule, self).__init__(component) self.fixTooManyPins=False self.fixNoFootprint=False diff --git a/schlib/rules/rule.py b/schlib/rules/rule.py index d7029b30..395ac57f 100644 --- a/schlib/rules/rule.py +++ b/schlib/rules/rule.py @@ -67,14 +67,15 @@ def positionFormater(element): # return "pos [{0},{1}]".format(element['posx'],element['posy']) class KLCRule(KLCRuleBase): - """ - A base class to represent a KLC rule + """A base class to represent a KLC rule + + Create the methods check and fix to use with the kicad lib files. """ verbosity = 0 - def __init__(self, component, description): + def __init__(self, component): - KLCRuleBase.__init__(self, description) + KLCRuleBase.__init__(self) - self.component = component \ No newline at end of file + self.component = component