mirror of
https://github.com/nophead/NopSCADlib.git
synced 2025-08-15 03:43:57 +02:00
Fixed bom.py, views.py and tests.py so that vitamin descriptions can contain more than one colon.
This commit is contained in:
@@ -140,7 +140,7 @@ class BOM:
|
|||||||
for part in sorted(self.vitamins):
|
for part in sorted(self.vitamins):
|
||||||
i += 1
|
i += 1
|
||||||
if ': ' in part:
|
if ': ' in part:
|
||||||
part_no, description = part.split(': ')
|
part_no, description = part.split(': ', 1)
|
||||||
else:
|
else:
|
||||||
part_no, description = "", part
|
part_no, description = "", part
|
||||||
qty = self.vitamins[part].count
|
qty = self.vitamins[part].count
|
||||||
@@ -183,7 +183,7 @@ class BOM:
|
|||||||
|
|
||||||
for part in sorted(self.vitamins):
|
for part in sorted(self.vitamins):
|
||||||
if ': ' in part:
|
if ': ' in part:
|
||||||
part_no, description = part.split(': ')
|
part_no, description = part.split(': ', 1)
|
||||||
else:
|
else:
|
||||||
part_no, description = "", part
|
part_no, description = "", part
|
||||||
if breakdown:
|
if breakdown:
|
||||||
|
@@ -259,11 +259,11 @@ def tests(tests):
|
|||||||
things = BOM[thing]
|
things = BOM[thing]
|
||||||
if things:
|
if things:
|
||||||
body += ['### %s\n| Qty | %s |\n| ---:|:--- |%s' % (thing.title(), heading, ':---|' if '|' in heading else '')]
|
body += ['### %s\n| Qty | %s |\n| ---:|:--- |%s' % (thing.title(), heading, ':---|' if '|' in heading else '')]
|
||||||
for item in sorted(things, key = lambda s: s.split(":")[-1]):
|
for item in sorted(things, key = lambda s: s.split(":",1)[-1]):
|
||||||
name = item
|
name = item
|
||||||
desc = ''
|
desc = ''
|
||||||
if thing == "vitamins":
|
if thing == "vitamins":
|
||||||
vit = item.split(':')
|
vit = item.split(':', 1)
|
||||||
name = '`' + vit[0] + '`' if vit[0] else ''
|
name = '`' + vit[0] + '`' if vit[0] else ''
|
||||||
while '[[' in name and ']]' in name:
|
while '[[' in name and ']]' in name:
|
||||||
i = name.find('[[')
|
i = name.find('[[')
|
||||||
|
@@ -303,7 +303,7 @@ def views(target, do_assemblies = None):
|
|||||||
grand_total2 = 0
|
grand_total2 = 0
|
||||||
heading = headings[t][0].upper() + headings[t][1:]
|
heading = headings[t][0].upper() + headings[t][1:]
|
||||||
print(('| ' * len(global_bom) + '| | **%s** |') % heading, file = doc_file)
|
print(('| ' * len(global_bom) + '| | **%s** |') % heading, file = doc_file)
|
||||||
for thing in sorted(things[t], key = lambda s: s.split(":")[-1]):
|
for thing in sorted(things[t], key = lambda s: s.split(":",1)[-1]):
|
||||||
for ass in global_bom:
|
for ass in global_bom:
|
||||||
count = ass[t][thing]["count"] if thing in ass[t] else 0
|
count = ass[t][thing]["count"] if thing in ass[t] else 0
|
||||||
print('| %s ' % pad(count if count else '.', 2, 1), file = doc_file, end = '')
|
print('| %s ' % pad(count if count else '.', 2, 1), file = doc_file, end = '')
|
||||||
@@ -313,7 +313,7 @@ def views(target, do_assemblies = None):
|
|||||||
else:
|
else:
|
||||||
totals[name] = count
|
totals[name] = count
|
||||||
grand_total2 += count
|
grand_total2 += count
|
||||||
print('| %s | %s |' % (pad(things[t][thing], 2, 1), pad(thing.split(":")[-1], 2)), file = doc_file)
|
print('| %s | %s |' % (pad(things[t][thing], 2, 1), pad(thing.split(":",1)[-1], 2)), file = doc_file)
|
||||||
|
|
||||||
grand_total = 0
|
grand_total = 0
|
||||||
for ass in global_bom:
|
for ass in global_bom:
|
||||||
@@ -344,8 +344,8 @@ def views(target, do_assemblies = None):
|
|||||||
print("### Vitamins", file = doc_file)
|
print("### Vitamins", file = doc_file)
|
||||||
print("|Qty|Description|", file = doc_file)
|
print("|Qty|Description|", file = doc_file)
|
||||||
print("|---:|:----------|", file = doc_file)
|
print("|---:|:----------|", file = doc_file)
|
||||||
for v in sorted(vitamins, key = lambda s: s.split(":")[-1]):
|
for v in sorted(vitamins, key = lambda s: s.split(":",1)[-1]):
|
||||||
print("|%d|%s|" % (vitamins[v]["count"], v.split(":")[1]), file = doc_file)
|
print("|%d|%s|" % (vitamins[v]["count"], v.split(":",1)[1]), file = doc_file)
|
||||||
print("\n", file = doc_file)
|
print("\n", file = doc_file)
|
||||||
|
|
||||||
printed = ass["printed"]
|
printed = ass["printed"]
|
||||||
|
Reference in New Issue
Block a user