]> git.gag.com Git - hw/altusmetrum/commitdiff
assume stdout which simplifies things significantly
authorBdale Garbee <bdale@gag.com>
Thu, 26 Dec 2019 11:39:51 +0000 (08:39 -0300)
committerBdale Garbee <bdale@gag.com>
Thu, 26 Dec 2019 11:39:51 +0000 (08:39 -0300)
packages/fplht.py

index e4bbc5041797b62e2a3f197aab4cb9d51e4951cf..e169792880c7d7a841b70cf1e23919415e232e49 100644 (file)
@@ -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 
+# <something>.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("}")