mirror of
https://github.com/nophead/NopSCADlib.git
synced 2025-08-13 19:03:58 +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):
|
||||
i += 1
|
||||
if ': ' in part:
|
||||
part_no, description = part.split(': ')
|
||||
part_no, description = part.split(': ', 1)
|
||||
else:
|
||||
part_no, description = "", part
|
||||
qty = self.vitamins[part].count
|
||||
@@ -183,7 +183,7 @@ class BOM:
|
||||
|
||||
for part in sorted(self.vitamins):
|
||||
if ': ' in part:
|
||||
part_no, description = part.split(': ')
|
||||
part_no, description = part.split(': ', 1)
|
||||
else:
|
||||
part_no, description = "", part
|
||||
if breakdown:
|
||||
|
@@ -259,11 +259,11 @@ def tests(tests):
|
||||
things = BOM[thing]
|
||||
if things:
|
||||
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
|
||||
desc = ''
|
||||
if thing == "vitamins":
|
||||
vit = item.split(':')
|
||||
vit = item.split(':', 1)
|
||||
name = '`' + vit[0] + '`' if vit[0] else ''
|
||||
while '[[' in name and ']]' in name:
|
||||
i = name.find('[[')
|
||||
|
@@ -303,7 +303,7 @@ def views(target, do_assemblies = None):
|
||||
grand_total2 = 0
|
||||
heading = headings[t][0].upper() + headings[t][1:]
|
||||
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:
|
||||
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 = '')
|
||||
@@ -313,7 +313,7 @@ def views(target, do_assemblies = None):
|
||||
else:
|
||||
totals[name] = 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
|
||||
for ass in global_bom:
|
||||
@@ -344,8 +344,8 @@ def views(target, do_assemblies = None):
|
||||
print("### Vitamins", file = doc_file)
|
||||
print("|Qty|Description|", file = doc_file)
|
||||
print("|---:|:----------|", file = doc_file)
|
||||
for v in sorted(vitamins, key = lambda s: s.split(":")[-1]):
|
||||
print("|%d|%s|" % (vitamins[v]["count"], v.split(":")[1]), file = doc_file)
|
||||
for v in sorted(vitamins, key = lambda s: s.split(":",1)[-1]):
|
||||
print("|%d|%s|" % (vitamins[v]["count"], v.split(":",1)[1]), file = doc_file)
|
||||
print("\n", file = doc_file)
|
||||
|
||||
printed = ass["printed"]
|
||||
|
Reference in New Issue
Block a user