def parse(cls, n): element = attributes.parse(cls, n, constants.ATTRIBUTES.ELEMENT) pad = attributes.parse(cls, n, constants.ATTRIBUTES.PAD) route = attributes.parse_or_default(cls, n, constants.ATTRIBUTES.ROUTE, cls.DEFAULT_ROUTE) route_tag = attributes.parse_or_default(cls, n, constants.ATTRIBUTES.ROUTE_TAG, cls.DEFAULT_ROUTE_TAG) return Contact_Ref(element, pad, route, route_tag)
def parse(cls, n): x = attributes.parse(cls, n, constants.ATTRIBUTES.X) y = attributes.parse(cls, n, constants.ATTRIBUTES.Y) size = attributes.parse(cls, n, constants.ATTRIBUTES.SIZE) layer = attributes.parse(cls, n, constants.ATTRIBUTES.LAYER) xref = attributes.parse_or_default(cls, n, constants.ATTRIBUTES.XREF, cls.DEFAULT_XREF) rotation = attributes.parse_or_default(cls, n, constants.ATTRIBUTES.ROTATION, attributes.Rotation(0)) font = attributes.parse_or_default(cls, n, constants.ATTRIBUTES.FONT, cls.DEFAULT_FONT) ratio = attributes.parse_or_default(cls, n, constants.ATTRIBUTES.RATIO, cls.DEFAULT_RATIO) return Label(x, y, size, layer, xref, rotation, font, ratio)
def parse(cls, n): x = attributes.parse(cls, n, constants.ATTRIBUTES.X) y = attributes.parse(cls, n, constants.ATTRIBUTES.Y) drill = attributes.parse(cls, n, constants.ATTRIBUTES.DRILL) diameter = attributes.parse_or_default(cls, n, constants.ATTRIBUTES.DIAMETER, None) rotation = attributes.parse_or_default(cls, n, constants.ATTRIBUTES.ROTATION, attributes.Rotation(0)) extent = attributes.parse_or_default(cls, n, constants.ATTRIBUTES.EXTENT, cls.DEFAULT_EXTENT) always_stop = attributes.parse_or_default(cls, n, constants.ATTRIBUTES.ALWAYS_STOP, cls.DEFAULT_ALWAYS_STOP) shape = attributes.parse_or_default(cls, n, constants.ATTRIBUTES.SHAPE, cls.DEFAULT_SHAPE) return Via(x, y, drill, diameter, rotation, extent, always_stop, shape)
def parse(cls, n): x1 = attributes.parse(cls, n, constants.ATTRIBUTES.X1) y1 = attributes.parse(cls, n, constants.ATTRIBUTES.Y1) x2 = attributes.parse(cls, n, constants.ATTRIBUTES.X2) y2 = attributes.parse(cls, n, constants.ATTRIBUTES.Y2) width = attributes.parse(cls, n, constants.ATTRIBUTES.WIDTH) layer = attributes.parse(cls, n, constants.ATTRIBUTES.LAYER) curve = attributes.parse_or_default(cls, n, constants.ATTRIBUTES.CURVE, cls.DEFAULT_CURVE) extent = attributes.parse_or_default(cls, n, constants.ATTRIBUTES.EXTENT, cls.DEFAULT_EXTENT) style = attributes.parse_or_default(cls, n, constants.ATTRIBUTES.STYLE, cls.DEFAULT_STYLE) cap = attributes.parse_or_default(cls, n, constants.ATTRIBUTES.CAP, cls.DEFAULT_CAP) return Wire(x1, y1, x2, y2, width, layer, curve, extent, style, cap)
def parse(cls, n): x = attributes.parse(cls, n, constants.ATTRIBUTES.X) y = attributes.parse(cls, n, constants.ATTRIBUTES.Y) radius = attributes.parse(cls, n, constants.ATTRIBUTES.RADIUS) width = attributes.parse_or_default(cls, n, constants.ATTRIBUTES.WIDTH, cls.DEFAULT_WIDTH) layer = attributes.parse(cls, n, constants.ATTRIBUTES.LAYER) return Circle(x, y, radius, layer, width)
def parse(cls, n): x1 = attributes.parse(cls, n, constants.ATTRIBUTES.X1) y1 = attributes.parse(cls, n, constants.ATTRIBUTES.Y1) x2 = attributes.parse(cls, n, constants.ATTRIBUTES.X2) y2 = attributes.parse(cls, n, constants.ATTRIBUTES.Y2) layer = attributes.parse(cls, n, constants.ATTRIBUTES.LAYER) rotation = attributes.parse_or_default(cls, n, constants.ATTRIBUTES.ROTATION, attributes.Rotation(0)) return Rectangle(x1, y1, x2, y2, layer, rotation)
def parse(cls, n): x1 = attributes.parse(cls, n, constants.ATTRIBUTES.X1) y1 = attributes.parse(cls, n, constants.ATTRIBUTES.Y1) x2 = attributes.parse(cls, n, constants.ATTRIBUTES.X2) y2 = attributes.parse(cls, n, constants.ATTRIBUTES.Y2) x3 = attributes.parse(cls, n, constants.ATTRIBUTES.X3) y3 = attributes.parse(cls, n, constants.ATTRIBUTES.Y3) layer = attributes.parse(cls, n, constants.ATTRIBUTES.LAYER) text_size = attributes.parse_or_default(cls, n, constants.ATTRIBUTES.TEXT_SIZE, cls.DEFAULT_TEXT_SIZE) text_ratio = attributes.parse_or_default(cls, n, constants.ATTRIBUTES.TEXT_RATIO, cls.DEFAULT_TEXT_RATIO) dimension_type = attributes.parse_or_default(cls, n, constants.ATTRIBUTES.DIMENSION_TYPE, cls.DEFAULT_DIMENSION_TYPE) width = attributes.parse_or_default(cls, n, constants.ATTRIBUTES.WIDTH, cls.DEFAULT_WIDTH) ext_width = attributes.parse_or_default(cls, n, constants.ATTRIBUTES.EXT_WIDTH, cls.DEFAULT_EXT_WIDTH) ext_length = attributes.parse_or_default(cls, n, constants.ATTRIBUTES.EXT_LENGTH, cls.DEFAULT_EXT_LENGTH) ext_offset = attributes.parse_or_default(cls, n, constants.ATTRIBUTES.EXT_OFFSET, cls.DEFAULT_EXT_OFFSET) unit = attributes.parse_or_default(cls, n, constants.ATTRIBUTES.UNIT, cls.DEFAULT_UNIT) precision = attributes.parse_or_default(cls, n, constants.ATTRIBUTES.PRECISION, cls.DEFAULT_PRECISION) unit_visible = attributes.parse_or_default(cls, n, constants.ATTRIBUTES.VISIBLE, cls.DEFAULT_UNIT_VISIBLE) return Dimension(x1, y1, x2, y2, x3, y3, layer, text_size, text_ratio, dimension_type, width, ext_width, ext_length, ext_offset, unit, precision, unit_visible)
def parse(cls, n): name = attributes.parse(cls, n, constants.ATTRIBUTES.NAME) x = attributes.parse(cls, n, constants.ATTRIBUTES.X) y = attributes.parse(cls, n, constants.ATTRIBUTES.Y) visible = attributes.parse_or_default(cls, n, constants.ATTRIBUTES.VISIBLE, cls.DEFAULT_VISIBLE) swap_level = attributes.parse_or_default(cls, n, constants.ATTRIBUTES.SWAP_LEVEL, cls.DEFAULT_SWAP_LEVEL) rotation = attributes.parse_or_default(cls, n, constants.ATTRIBUTES.ROTATION, attributes.Rotation()) length = attributes.parse_or_default(cls, n, constants.ATTRIBUTES.LENGTH, cls.DEFAULT_LENGTH) direction = attributes.parse_or_default(cls, n, constants.ATTRIBUTES.DIRECTION, cls.DEFAULT_DIRECTION) function = attributes.parse_or_default(cls, n, constants.ATTRIBUTES.FUNCTION, cls.DEFAULT_FUNCTION) return Pin(name, x, y, visible, swap_level, rotation, length, direction, function)
def parse(cls, n): name = attributes.parse(cls, n, constants.ATTRIBUTES.NAME) x = attributes.parse(cls, n, constants.ATTRIBUTES.X) y = attributes.parse(cls, n, constants.ATTRIBUTES.Y) drill = attributes.parse(cls, n, constants.ATTRIBUTES.DRILL) diameter = attributes.parse_or_default(cls, n, constants.ATTRIBUTES.DIAMETER, None) rotation = attributes.parse_or_default(cls, n, constants.ATTRIBUTES.ROTATION, attributes.Rotation()) shape = attributes.parse_or_default(cls, n, constants.ATTRIBUTES.SHAPE, cls.DEFAULT_SHAPE) first = attributes.parse_or_default(cls, n, constants.ATTRIBUTES.FIRST, cls.DEFAULT_FIRST) stop = attributes.parse_or_default(cls, n, constants.ATTRIBUTES.STOP, cls.DEFAULT_STOP) thermals = attributes.parse_or_default(cls, n, constants.ATTRIBUTES.THERMALS, cls.DEFAULT_THERMALS) return Pad(name, x, y, drill, diameter, rotation, shape, first, stop, thermals)
def parse(cls, n): layer = attributes.parse(cls, n, constants.ATTRIBUTES.LAYER) width = attributes.parse_or_default(cls, n, constants.ATTRIBUTES.WIDTH, cls.DEFAULT_WIDTH) rank = attributes.parse_or_default(cls, n, constants.ATTRIBUTES.RANK, cls.DEFAULT_RANK) spacing = attributes.parse_or_default(cls, n, constants.ATTRIBUTES.SPACING, cls.DEFAULT_SPACING) pour = attributes.parse_or_default(cls, n, constants.ATTRIBUTES.POUR, cls.DEFAULT_POUR) isolate = attributes.parse_or_default(cls, n, constants.ATTRIBUTES.ISOLATE, cls.DEFAULT_ISOLATE) orphans = attributes.parse_or_default(cls, n, constants.ATTRIBUTES.ORPHANS, cls.DEFAULT_ORPHANS) thermals = attributes.parse_or_default(cls, n, constants.ATTRIBUTES.THERMALS, cls.DEFAULT_THERMALS) # Get the points n_vertex_arr = n.findall(constants.TAGS.VERTEX) points = [] for nv in n_vertex_arr: x = attributes.parse(cls, nv, constants.ATTRIBUTES.X) y = attributes.parse(cls, nv, constants.ATTRIBUTES.Y) curve = attributes.parse_or_default(cls, nv, constants.ATTRIBUTES.CURVE, 0) points.append((x, y, curve)) return Polygon(layer, points = points, width = width, rank = rank, spacing = spacing, pour = pour, isolate = isolate, orphans = orphans, thermals = thermals)
def parse(cls, n): name = attributes.parse(cls, n, constants.ATTRIBUTES.NAME) x = attributes.parse(cls, n, constants.ATTRIBUTES.X) y = attributes.parse(cls, n, constants.ATTRIBUTES.Y) dx = attributes.parse(cls, n, constants.ATTRIBUTES.DX) dy = attributes.parse(cls, n, constants.ATTRIBUTES.DY) layer = attributes.parse(cls, n, constants.ATTRIBUTES.LAYER) rotation = attributes.parse_or_default(cls, n, constants.ATTRIBUTES.ROTATION, attributes.Rotation()) roundness = attributes.parse_or_default(cls, n, constants.ATTRIBUTES.ROUNDNESS, cls.DEFAULT_ROUNDNESS) cream = attributes.parse_or_default(cls, n, constants.ATTRIBUTES.CREAM, cls.DEFAULT_CREAM) first = attributes.parse_or_default(cls, n, constants.ATTRIBUTES.FIRST, cls.DEFAULT_FIRST) stop = attributes.parse_or_default(cls, n, constants.ATTRIBUTES.STOP, cls.DEFAULT_STOP) thermals = attributes.parse_or_default(cls, n, constants.ATTRIBUTES.THERMALS, cls.DEFAULT_THERMALS) return SMD(name, x, y, dx, dy, layer, rotation, roundness, cream, first, stop, thermals)
def parse(cls, n): x1 = attributes.parse(cls, n, constants.ATTRIBUTES.X1) y1 = attributes.parse(cls, n, constants.ATTRIBUTES.Y1) x2 = attributes.parse(cls, n, constants.ATTRIBUTES.X2) y2 = attributes.parse(cls, n, constants.ATTRIBUTES.Y2) rows = attributes.parse_or_default(cls, n, constants.ATTRIBUTES.ROWS, cls.DEFAULT_ROWS) columns = attributes.parse_or_default(cls, n, constants.ATTRIBUTES.COLUMNS, cls.DEFAULT_COLUMNS) layer = attributes.parse(cls, n, constants.ATTRIBUTES.LAYER) border_top = attributes.parse_or_default(cls, n, constants.ATTRIBUTES.BORDER.TOP, cls.DEFAULT_BORDER_TOP) border_left = attributes.parse_or_default(cls, n, constants.ATTRIBUTES.BORDER.LEFT, cls.DEFAULT_BORDER_LEFT) border_bottom = attributes.parse_or_default(cls, n, constants.ATTRIBUTES.BORDER.BOTTOM, cls.DEFAULT_BORDER_BOTTOM) border_right = attributes.parse_or_default(cls, n, constants.ATTRIBUTES.BORDER.RIGHT, cls.DEFAULT_BORDER_RIGHT) return Frame(x1, y1, x2, y2, layer, rows, columns, border_left, border_top, border_right, border_bottom)
def parse(cls, n): value = n.text x = attributes.parse(cls, n, constants.ATTRIBUTES.X) y = attributes.parse(cls, n, constants.ATTRIBUTES.Y) layer = attributes.parse(cls, n, constants.ATTRIBUTES.LAYER) size = attributes.parse(cls, n, constants.ATTRIBUTES.SIZE) align = attributes.parse_or_default(cls, n, constants.ATTRIBUTES.ALIGN, cls.DEFAULT_ALIGN) font = attributes.parse_or_default(cls, n, constants.ATTRIBUTES.FONT, cls.DEFAULT_FONT) rotation = attributes.parse_or_default(cls, n, constants.ATTRIBUTES.ROTATION, attributes.Rotation()) ratio = attributes.parse_or_default(cls, n, constants.ATTRIBUTES.RATIO, cls.DEFAULT_RATIO) distance = attributes.parse_or_default(cls, n, constants.ATTRIBUTES.DISTANCE, cls.DEFAULT_DISTANCE) spin = attributes.parse_or_default(cls, n, constants.ATTRIBUTES.SPIN, cls.DEFAULT_SPIN) return Text(value, x, y, layer, size, align, font, rotation, ratio, distance, spin)