From c666c032c1ed88c2748ba5f56b13887e62fb2b36 Mon Sep 17 00:00:00 2001 From: Bdale Garbee Date: Thu, 26 Dec 2019 08:39:51 -0300 Subject: [PATCH] assume stdout which simplifies things significantly --- packages/fplht.py | 96 +++++++++++++++++++++++------------------------ 1 file changed, 48 insertions(+), 48 deletions(-) diff --git a/packages/fplht.py b/packages/fplht.py index e4bbc50..e169792 100644 --- a/packages/fplht.py +++ b/packages/fplht.py @@ -3,14 +3,17 @@ # Python library to assist in generating lihata format footprints for pcb-rnd +# Each footprint should have a parent Python script that initializes this +# library and provides a high-level description of the primitives required. +# The footprint is delivered to stdout, so the encapsulating Makefile and/or +# iterating wrapper script is responsible for redirecting to the desired +# .lht file(s). + import math -import sys import hashlib class footprint(object): - def __init__(self, - output = sys.stdout): - self.output = output + def __init__(self): self.units = "mm" self.name = "" self.description = "" @@ -42,70 +45,67 @@ class footprint(object): # def arc(): # x, y, width, height, startangle, deltaangle, thickness - def writeln(self, stuff): - self.output.write(stuff + "\n") - def emit_padstack_prototypes(self): - self.writeln("prototypes will go here") + print("prototypes will go here") def emit_padstacks(self): - self.writeln("padstacks will go here") + print("padstacks will go here") def emit_top_silk(self): - self.writeln("top_silk will go here") + print("top_silk will go here") def emit_line(self, role, id, x1, y1, x2, y2, unit): - self.writeln(" ha:line.%u {" % id) - self.writeln(" clearance = 0") - self.writeln(" thickness = 0") - self.writeln(" ha:attributes {") - self.writeln(" subc-role = %s" % role) - self.writeln(" }") - self.writeln(" x1 = %u%s" % (x1, unit)) - self.writeln(" y1 = %u%s" % (y1, unit)) - self.writeln(" x2 = %u%s" % (x2, unit)) - self.writeln(" y2 = %u%s" % (y2, unit)) - self.writeln(" }") + print(" ha:line.%u {" % id) + print(" clearance = 0") + print(" thickness = 0") + print(" ha:attributes {") + print(" subc-role = %s" % role) + print(" }") + print(" x1 = %u%s" % (x1, unit)) + print(" y1 = %u%s" % (y1, unit)) + print(" x2 = %u%s" % (x2, unit)) + print(" y2 = %u%s" % (y2, unit)) + print(" }") self.cnt = self.cnt + 1 def emit_bbox(self): self.cnt = 0 - self.writeln(" ha:subc-aux {") - self.writeln(" lid = 1") - self.writeln(" ha:type {") - self.writeln(" top = 1") - self.writeln(" misc = 1") - self.writeln(" virtual = 1") - self.writeln(" }") - self.writeln(" li:objects {") + print(" ha:subc-aux {") + print(" lid = 1") + print(" ha:type {") + print(" top = 1") + print(" misc = 1") + print(" virtual = 1") + print(" }") + print(" li:objects {") self.emit_line("origin", self.cnt, 0, 0, 0, 0, "mm"); self.emit_line("x", self.cnt, 0, 0, 1, 0, "mm"); self.emit_line("y", self.cnt, 0, 0, 0, 1, "mm"); - self.writeln(" }") - self.writeln(" }") + print(" }") + print(" }") def create_uuid(self): return hashlib.md5(self.name).hexdigest() def emit(self): - self.writeln("li:pcb-rnd-subcircuit-v4 {") - self.writeln(" ha:subc.0 {") - self.writeln(" ha:attributes {") - self.writeln(" description = %s" % self.description) - self.writeln(" dist_license = %s" % self.dist_license) - self.writeln(" use_license = %s" % self.use_license) - self.writeln(" author = %s" % self.author) - self.writeln(" }") - self.writeln(" uid = %s" % self.create_uuid()) - self.writeln(" ha:data {") + print("li:pcb-rnd-subcircuit-v4 {") + print(" ha:subc.0 {") + print(" ha:attributes {") + print(" description = %s" % self.description) + print(" dist_license = %s" % self.dist_license) + print(" use_license = %s" % self.use_license) + print(" author = %s" % self.author) + print(" }") + print(" uid = %s" % self.create_uuid()) + print(" ha:data {") self.emit_padstack_prototypes() - self.writeln(" li:objects {") + print(" li:objects {") self.emit_padstacks() - self.writeln(" }") - self.writeln(" li:layers {") + print(" }") + print(" li:layers {") self.emit_top_silk() self.emit_bbox() - self.writeln(" }") - self.writeln(" }") - self.writeln(" }") - self.writeln("}") + print(" }") + print(" }") + print(" }") + print("}") -- 2.47.2