Pcbnew Python: use python super for inherited classes

This commit is contained in:
John Beard 2018-06-13 12:13:37 +01:00 committed by Wayne Stambaugh
parent 1f04b5fc7d
commit 41d6fc648d
1 changed files with 19 additions and 19 deletions

View File

@ -24,7 +24,7 @@ from __future__ import division
import math import math
import pcbnew import pcbnew
class PadMaker: class PadMaker(object):
"""! """!
Useful construction functions for common types of pads, providing Useful construction functions for common types of pads, providing
sensible defaults for common pads. sensible defaults for common pads.
@ -106,7 +106,7 @@ class PadMaker:
return pad return pad
class PadArray: class PadArray(object):
"""! """!
A class to assist in creating repetitive grids of pads A class to assist in creating repetitive grids of pads
@ -118,9 +118,16 @@ class PadArray:
types. types.
""" """
def __init__(self): def __init__(self, pad):
"""!
@param pad: the prototypical pad
"""
self.firstPadNum = 1 self.firstPadNum = 1
self.pinNames = None self.pinNames = None
# this pad is more of a "context", we will use it as a source of
# pad data, but not actually add it
self.pad = pad
self.firstPad = None self.firstPad = None
def SetPinNames(self, pinNames): def SetPinNames(self, pinNames):
@ -205,11 +212,8 @@ class PadGridArray(PadArray):
@param py: pitch in y-direction @param py: pitch in y-direction
@param centre: array centre point @param centre: array centre point
""" """
PadArray.__init__(self) super(PadGridArray, self).__init__(pad)
# this pad is more of a "context", we will use it as a source of
# pad data, but not actually add it
self.pad = pad
self.nx = int(nx) self.nx = int(nx)
self.ny = int(ny) self.ny = int(ny)
self.px = px self.px = px
@ -298,10 +302,8 @@ class PadZGridArray(PadArray):
@param pad_pitch: distance between pads in a line @param pad_pitch: distance between pads in a line
@param centre: array centre point @param centre: array centre point
""" """
PadArray.__init__(self) super(PadZGridArray, self).__init__(pad)
# this pad is more of a "context", we will use it as a source of
# pad data, but not actually add it
self.pad = pad
self.pad_count = int(pad_count) self.pad_count = int(pad_count)
self.line_count = int(line_count) self.line_count = int(line_count)
self.line_pitch = line_pitch self.line_pitch = line_pitch
@ -358,9 +360,9 @@ class PadLineArray(PadGridArray):
""" """
if isVertical: if isVertical:
PadGridArray.__init__(self, pad, 1, n, 0, pitch, centre) super(PadLineArray, self).__init__(pad, 1, n, 0, pitch, centre)
else: else:
PadGridArray.__init__(self, pad, n, 1, pitch, 0, centre) super(PadLineArray, self).__init__(pad, n, 1, pitch, 0, centre)
class PadCircleArray(PadArray): class PadCircleArray(PadArray):
@ -381,10 +383,8 @@ class PadCircleArray(PadArray):
@param padRotationOffset: rotation of first pad @param padRotationOffset: rotation of first pad
""" """
PadArray.__init__(self) super(PadCircleArray, self).__init__(pad)
# this pad is more of a "context", we will use it as a source of
# pad data, but not actually add it
self.pad = pad
self.n = int(n) self.n = int(n)
self.r = r self.r = r
self.angle_offset = angle_offset self.angle_offset = angle_offset
@ -434,8 +434,8 @@ class PadCustomArray(PadArray):
@param pad: the prototypical pad @param pad: the prototypical pad
@param array: the position data array @param array: the position data array
""" """
PadArray.__init__(self) super(PadCustomArray, self).__init__(pad)
self.pad = pad
self.array = array self.array = array
def NamingFunction(self, n): def NamingFunction(self, n):