Changed the default `group_fields` list.

Internal BoM: now components with different Tolerance, Voltage, Current
and/or Power fields aren't grouped together.
These fields are now part of the default `group_fields`. (#79)
This commit is contained in:
Salvador E. Tropea 2021-09-27 11:31:51 -03:00
parent e902c7350d
commit 0f0e739026
8 changed files with 24 additions and 10 deletions

View File

@ -12,6 +12,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- skip_bottom: bottom components aren't rotated.
- XLSX BoM: option to control the logo scale (#84)
### Changed
- Internal BoM: now components with different Tolerance, Voltage, Current
and/or Power fields aren't grouped together.
These fields are now part of the default `group_fields`. (#79)
### Fixed
- Position files now defaults to use the auxiliar origin as KiCad.
Can be disabled to use absolute coordinates. (#87)

View File

@ -692,7 +692,8 @@ Next time you need this list just use an alias, like this:
- `group_fields`: [list(string)] List of fields used for sorting individual components into groups.
Components which match (comparing *all* fields) will be grouped together.
Field names are case-insensitive.
If empty: ['Part', 'Part Lib', 'Value', 'Footprint', 'Footprint Lib'] is used.
If empty: ['Part', 'Part Lib', 'Value', 'Footprint', 'Footprint Lib',
'Voltage', 'Tolerance', 'Current', 'Power'] is used.
- `group_fields_fallbacks`: [list(string)] List of fields to be used when the fields in `group_fields` are empty.
The first field in this list is the fallback for the first in `group_fields`, and so on.
- `html`: [dict] Options for the HTML format.

View File

@ -130,8 +130,9 @@ outputs:
# [list(string)] List of fields used for sorting individual components into groups.
# Components which match (comparing *all* fields) will be grouped together.
# Field names are case-insensitive.
# If empty: ['Part', 'Part Lib', 'Value', 'Footprint', 'Footprint Lib'] is used
group_fields: ['part', 'part lib', 'value', 'footprint', 'footprint lib']
# If empty: ['Part', 'Part Lib', 'Value', 'Footprint', 'Footprint Lib',
# 'Voltage', 'Tolerance', 'Current', 'Power'] is used
group_fields: ['part', 'part lib', 'value', 'footprint', 'footprint lib', 'voltage', 'tolerance', 'current', 'power']
# [list(string)] List of fields to be used when the fields in `group_fields` are empty.
# The first field in this list is the fallback for the first in `group_fields`, and so on
group_fields_fallbacks:

View File

@ -405,8 +405,8 @@ def print_example_options(f, cls, name, indent, po, is_list=False):
# Get the text before the space, without the ]
txt = txt.split()[0][:-1]
f.write(ind_str+'{}: {}\n'.format(k, txt))
elif hasattr(val, '_default'):
f.write(ind_str+'{}: {}\n'.format(k, val._default))
elif val.get_default():
f.write(ind_str+'{}: {}\n'.format(k, val.get_default()))
else:
f.write(ind_str+'{}:\n'.format(k))
print_example_options(f, val, '', indent+2, None, help and 'list(dict' in help_lines[0])

View File

@ -25,6 +25,7 @@ class Optionable(object):
Is configured from a dict and the collected values are stored in its attributes. """
_str_values_re = compile(r"string=.*\] \[([^\]]+)\]")
_num_range_re = compile(r"number=.*\] \[(-?\d+),(-?\d+)\]")
_default = None
def __init__(self):
self._unkown_is_error = False
@ -253,6 +254,10 @@ class Optionable(object):
val = []
return val
@classmethod
def get_default(cls):
return cls._default
class BaseOptions(Optionable):
""" A class to validate and hold output options.

View File

@ -183,7 +183,7 @@ class ComponentAliases(Optionable):
class GroupFields(Optionable):
_default = ColumnList.DEFAULT_GROUPING
_default = ColumnList.DEFAULT_GROUPING + ['voltage', 'tolerance', 'current', 'power']
def __init__(self):
super().__init__()
@ -274,7 +274,8 @@ class BoMOptions(BaseOptions):
""" [list(string)] List of fields used for sorting individual components into groups.
Components which match (comparing *all* fields) will be grouped together.
Field names are case-insensitive.
If empty: ['Part', 'Part Lib', 'Value', 'Footprint', 'Footprint Lib'] is used """
If empty: ['Part', 'Part Lib', 'Value', 'Footprint', 'Footprint Lib',
. 'Voltage', 'Tolerance', 'Current', 'Power'] is used """
self.group_fields_fallbacks = Optionable
""" [list(string)] List of fields to be used when the fields in `group_fields` are empty.
The first field in this list is the fallback for the first in `group_fields`, and so on """
@ -427,7 +428,7 @@ class BoMOptions(BaseOptions):
self.xlsx.config(self)
# group_fields
if isinstance(self.group_fields, type):
self.group_fields = ColumnList.DEFAULT_GROUPING
self.group_fields = GroupFields.get_default()
else:
# Make the grouping fields lowercase
self.group_fields = [f.lower() for f in self.group_fields]

View File

@ -32,4 +32,4 @@ outputs:
dir: BoM
options:
exclude_filter: 'exclude_any'
group_fields: ['Part', 'Part Lib', 'Value', 'Footprint', 'Footprint Lib']

View File

@ -7,4 +7,5 @@ outputs:
comment: "Bill of Materials in CSV format"
type: bom
dir: BoM
options:
group_fields: ['Part', 'Part Lib', 'Value', 'Footprint', 'Footprint Lib']