Fixed assembly counts in json nexted BOM.

Fixed assembly counts in build instructions.
This commit is contained in:
Chris Palmer 2019-06-17 19:34:46 +01:00
parent ad8d7ae311
commit 8d49f2b564
2 changed files with 6 additions and 4 deletions

View File

@ -54,11 +54,11 @@ class BOM:
self.routed = {} self.routed = {}
self.assemblies = {} self.assemblies = {}
def data(self, main): def data(self, main, count = 1):
return { return {
"name" : self.name, "name" : self.name,
"count" : self.count, "count" : count,
"assemblies" : [main.assemblies[ass].data(main) for ass in self.assemblies], "assemblies" : [main.assemblies[ass].data(main, self.assemblies[ass].count) for ass in self.assemblies],
"vitamins" : self.vitamins, "vitamins" : self.vitamins,
"printed" : self.printed, "printed" : self.printed,
"routed" : self.routed "routed" : self.routed

View File

@ -35,6 +35,7 @@ import blurb
import bom import bom
import shutil import shutil
from colorama import Fore from colorama import Fore
import copy
def is_assembly(s): def is_assembly(s):
return s[-9:] == '_assembly' or s[-11:] == '_assemblies' return s[-9:] == '_assembly' or s[-11:] == '_assemblies'
@ -42,6 +43,7 @@ def is_assembly(s):
def add_assembly(flat_bom, bom, bounds_map): def add_assembly(flat_bom, bom, bounds_map):
for b in flat_bom: for b in flat_bom:
if b["name"] == bom["name"]: if b["name"] == bom["name"]:
b["count"] += bom["count"]
return b return b
big = False big = False
for ass in bom["assemblies"]: for ass in bom["assemblies"]:
@ -58,7 +60,7 @@ def add_assembly(flat_bom, bom, bounds_map):
break break
bom["big"] = big or bom["routed"] bom["big"] = big or bom["routed"]
flat_bom.append(bom) flat_bom.append(copy.deepcopy(bom))
return bom return bom
def bom_to_assemblies(bom_dir, bounds_map): def bom_to_assemblies(bom_dir, bounds_map):