Added support for reference separator in BoMs.
So you can get things like "R1, R2, R3" From the following PR: SchrodingersGat/KiBoM#139 by @n0dyjeff
This commit is contained in:
parent
1ed960d045
commit
27e4c23236
|
|
@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
|
||||
## [Unreleased]
|
||||
### Added
|
||||
- The KiBoM and internal BoM generators now support configuring the
|
||||
separator used for the list of references.
|
||||
|
||||
## [0.7.0] - 2020-09-11
|
||||
### Added
|
||||
|
|
|
|||
|
|
@ -421,6 +421,7 @@ Next time you need this list just use an alias, like this:
|
|||
- `normalize_values`: [boolean=false] Try to normalize the R, L and C values, producing uniform units and prefixes.
|
||||
- `number`: [number=1] Number of boards to build (components multiplier).
|
||||
- `output`: [string='%f-%i%v.%x'] filename for the output (%i=bom). Affected by global options.
|
||||
- `ref_separator`: [string=' '] Separator used for the list of references.
|
||||
- `use_alt`: [boolean=false] Print grouped references in the alternate compressed style eg: R1-R7,R18.
|
||||
- `variant`: [string=''] Board variant, used to determine which components
|
||||
are output to the BoM..
|
||||
|
|
@ -733,6 +734,7 @@ Next time you need this list just use an alias, like this:
|
|||
- *regexp*: Alias for regex.
|
||||
- `merge_blank_fields`: [boolean=true] Component groups with blank fields will be merged into the most compatible group, where possible.
|
||||
- `number_rows`: [boolean=true] First column is the row number.
|
||||
- `ref_separator`: [string=' '] Separator used for the list of references.
|
||||
- `test_regex`: [boolean=true] Each component group will be tested against a number of regular-expressions (see ``)..
|
||||
- `use_alt`: [boolean=false] Print grouped references in the alternate compressed style eg: R1-R7,R18.
|
||||
- `format`: [string='HTML'] [HTML,CSV,XML,XLSX] format for the BoM.
|
||||
|
|
|
|||
|
|
@ -119,6 +119,8 @@ outputs:
|
|||
number: 1
|
||||
# [string='%f-%i%v.%x'] filename for the output (%i=bom). Affected by global options
|
||||
output: '%f-%i%v.%x'
|
||||
# [string=' '] Separator used for the list of references
|
||||
ref_separator: ' '
|
||||
# [boolean=false] Print grouped references in the alternate compressed style eg: R1-R7,R18
|
||||
use_alt: false
|
||||
# [string=''] Board variant, used to determine which components
|
||||
|
|
@ -519,6 +521,8 @@ outputs:
|
|||
merge_blank_fields: true
|
||||
# [boolean=true] First column is the row number
|
||||
number_rows: true
|
||||
# [string=' '] Separator used for the list of references
|
||||
ref_separator: ' '
|
||||
# [boolean=true] Each component group will be tested against a number of regular-expressions (see ``).
|
||||
test_regex: true
|
||||
# [boolean=false] Print grouped references in the alternate compressed style eg: R1-R7,R18
|
||||
|
|
|
|||
|
|
@ -190,7 +190,7 @@ class ComponentGroup(object):
|
|||
|
||||
def get_refs(self):
|
||||
""" Return a list of the components """
|
||||
return " ".join([c.ref for c in self.components])
|
||||
return self.cfg.ref_separator.join([c.ref for c in self.components])
|
||||
|
||||
def get_alt_refs(self):
|
||||
""" Alternative list of references using ranges """
|
||||
|
|
|
|||
|
|
@ -201,6 +201,8 @@ class BoMOptions(BaseOptions):
|
|||
""" Try to normalize the R, L and C values, producing uniform units and prefixes """
|
||||
self.normalize_locale = False
|
||||
""" When normalizing values use the locale decimal point """
|
||||
self.ref_separator = ' '
|
||||
""" Separator used for the list of references """
|
||||
self.html = BoMHTML
|
||||
""" [dict] Options for the HTML format """
|
||||
self.xlsx = BoMXLSX
|
||||
|
|
|
|||
|
|
@ -109,6 +109,8 @@ class KiBoMConfig(Optionable):
|
|||
""" Hide column headers """
|
||||
self.hide_pcb_info = False
|
||||
""" Hide project information """
|
||||
self.ref_separator = ' '
|
||||
""" Separator used for the list of references """
|
||||
self.digikey_link = Optionable
|
||||
""" [string|list(string)=''] Column/s containing Digi-Key part numbers, will be linked to web page (HTML only) """
|
||||
self.group_fields = GroupFields
|
||||
|
|
@ -299,6 +301,7 @@ class KiBoMConfig(Optionable):
|
|||
self.write_str('datasheet_as_link')
|
||||
self.write_bool('hide_headers')
|
||||
self.write_bool('hide_pcb_info')
|
||||
self.write_str('ref_separator')
|
||||
self.write_str('digikey_link')
|
||||
# Ask to keep the output name
|
||||
f.write('output_file_name = %O\n')
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ STATS_ROWS = ['Component Groups:', 'Component Count:', 'Fitted Components:', 'Nu
|
|||
DEF_TITLE = 'KiBot Bill of Materials'
|
||||
|
||||
|
||||
def check_kibom_test_netlist(rows, ref_column, groups, exclude, comps):
|
||||
def check_kibom_test_netlist(rows, ref_column, groups, exclude, comps, ref_sep=' '):
|
||||
""" Checks the kibom-test.sch expected results """
|
||||
# Groups
|
||||
assert len(rows) == groups
|
||||
|
|
@ -98,7 +98,7 @@ def check_kibom_test_netlist(rows, ref_column, groups, exclude, comps):
|
|||
if comps:
|
||||
components = []
|
||||
for r in rows:
|
||||
components.extend(r[ref_column].split(' '))
|
||||
components.extend(r[ref_column].split(ref_sep))
|
||||
assert len(components) == len(comps)
|
||||
logging.debug(str(len(comps)) + " components OK")
|
||||
# Excluded
|
||||
|
|
@ -219,12 +219,12 @@ def check_csv_info(r, info, stats):
|
|||
assert row == len(r)
|
||||
|
||||
|
||||
def kibom_verif(rows, header, skip_head=False, qty_name=QTY_COLUMN_NAME):
|
||||
def kibom_verif(rows, header, skip_head=False, qty_name=QTY_COLUMN_NAME, ref_sep=' '):
|
||||
if not skip_head:
|
||||
assert header == KIBOM_TEST_HEAD
|
||||
ref_column = header.index(REF_COLUMN_NAME)
|
||||
qty_column = header.index(qty_name)
|
||||
check_kibom_test_netlist(rows, ref_column, KIBOM_TEST_GROUPS, KIBOM_TEST_EXCLUDE, KIBOM_TEST_COMPONENTS)
|
||||
check_kibom_test_netlist(rows, ref_column, KIBOM_TEST_GROUPS, KIBOM_TEST_EXCLUDE, KIBOM_TEST_COMPONENTS, ref_sep)
|
||||
check_dnc(rows, 'R7', ref_column, qty_column)
|
||||
|
||||
|
||||
|
|
@ -1383,3 +1383,11 @@ def test_int_bom_variant_cl_gl():
|
|||
VARIANTE_PRJ_INFO[1] = 't1_v3'
|
||||
check_csv_info(info, VARIANTE_PRJ_INFO, [3, 20, 2, 1, 2])
|
||||
ctx.clean_up()
|
||||
|
||||
|
||||
def test_int_bom_ref_separator():
|
||||
ctx, out = kibom_setup('int_bom_ref_separator')
|
||||
rows, header, info = ctx.load_csv(out)
|
||||
check_csv_info(info, KIBOM_PRJ_INFO, KIBOM_STATS)
|
||||
kibom_verif(rows, header, ref_sep=',')
|
||||
ctx.clean_up()
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
# Example KiBot config file
|
||||
kibot:
|
||||
version: 1
|
||||
|
||||
outputs:
|
||||
- name: 'bom_internal'
|
||||
comment: "Bill of Materials in CSV format"
|
||||
type: bom
|
||||
dir: BoM
|
||||
options:
|
||||
ref_separator: ','
|
||||
|
||||
Loading…
Reference in New Issue