From 2cf87efb2782dd6a550ce982388ee41537fd7fbb Mon Sep 17 00:00:00 2001 From: Chris Palmer Date: Wed, 11 Jun 2014 21:18:55 +0100 Subject: [PATCH] bom.py parsing of OpenScad echo made more robust to get around bug in the MAC version of OpenScad. --- bom.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/bom.py b/bom.py index 3d02936..7b337b1 100755 --- a/bom.py +++ b/bom.py @@ -44,14 +44,15 @@ class BOM: name = ass.replace("_assembly","") longest = max(longest, len(name)) for i in range(longest): + line = "" for ass in sorted(self.assemblies): name = ass.replace("_assembly","").replace("_"," ").capitalize() index = i - (longest - len(name)) if index < 0: - print(" ", end=" ", file=file) + line += " " else: - print(" %s" % name[index], end=" ", file=file) - print(file=file) + line += (" %s " % name[index]) + print(line[:-1], file=file) for part in sorted(self.vitamins): if ': ' in part: @@ -102,8 +103,9 @@ def boms(machine): stack = [] for line in open("openscad.log"): - if line[:7] == 'ECHO: "': - s = line[7:-2] + pos = line.find('ECHO: "') + if pos > -1: + s = line[pos + 7 : line.rfind('"')] if s[-1] == '/': ass = s[:-1] if stack: