Various fixes in the generated example.
- Now we can have a `example` different than the default. - Added some _default members - Support for missing schematic when using --list Related to #40
This commit is contained in:
parent
86a62bb8ff
commit
b0cc64e5c5
|
|
@ -598,7 +598,7 @@ Next time you need this list just use an alias, like this:
|
|||
The default filter excludes test points, fiducial marks, mounting holes, etc.
|
||||
- `fit_field`: [string='Config'] Field name used for internal filters.
|
||||
- `format`: [string=''] [HTML,CSV,TXT,TSV,XML,XLSX] format for the BoM.
|
||||
If empty defaults to CSV or a guess according to the options..
|
||||
Defaults to CSV or a guess according to the options..
|
||||
- `group_connectors`: [boolean=true] Connectors with the same footprints will be grouped together, independent of the name of the connector.
|
||||
- `group_fields`: [list(string)] List of fields used for sorting individual components into groups.
|
||||
Components which match (comparing *all* fields) will be grouped together.
|
||||
|
|
|
|||
|
|
@ -37,11 +37,11 @@ outputs:
|
|||
# Can be just the name of the field
|
||||
columns:
|
||||
# [string=''] Name of the field to use for this column
|
||||
- field: ''
|
||||
- field: 'Row'
|
||||
# [list(string)|string=''] List of fields to join to this column
|
||||
join: ''
|
||||
# [string=''] Name to display in the header. The field is used when empty
|
||||
name: ''
|
||||
name: 'Line'
|
||||
# [list(list(string))] A series of values which are considered to be equivalent for the part name.
|
||||
# Each entry is a list of equivalen names. Example: ['c', 'c_small', 'cap' ]
|
||||
# will ensure the equivalent capacitor symbols can be grouped together.
|
||||
|
|
@ -75,8 +75,8 @@ outputs:
|
|||
# [string='Config'] Field name used for internal filters
|
||||
fit_field: 'Config'
|
||||
# [string=''] [HTML,CSV,TXT,TSV,XML,XLSX] format for the BoM.
|
||||
# If empty defaults to CSV or a guess according to the options.
|
||||
format: ''
|
||||
# Defaults to CSV or a guess according to the options.
|
||||
format: 'CSV'
|
||||
# [boolean=true] Connectors with the same footprints will be grouped together, independent of the name of the connector
|
||||
group_connectors: true
|
||||
# [list(string)] List of fields used for sorting individual components into groups.
|
||||
|
|
@ -114,7 +114,7 @@ outputs:
|
|||
# [list(string)] List of fields where we tolerate conflicts.
|
||||
# Use it to avoid undesired warnings.
|
||||
# By default the field indicated in `fit_field` and the field `part` are excluded
|
||||
no_conflict:
|
||||
no_conflict: ['Config', 'Part']
|
||||
# [boolean=false] When normalizing values use the locale decimal point
|
||||
normalize_locale: false
|
||||
# [boolean=false] Try to normalize the R, L and C values, producing uniform units and prefixes
|
||||
|
|
@ -448,11 +448,11 @@ outputs:
|
|||
# Can be just the name of the field
|
||||
columns:
|
||||
# [string=''] Name of the field to use for this column
|
||||
- field: ''
|
||||
- field: 'Row'
|
||||
# [list(string)|string=''] List of fields to join to this column
|
||||
join: ''
|
||||
# [string=''] Name to display in the header. The field is used when empty
|
||||
name: ''
|
||||
name: 'Line'
|
||||
# [list(list(string))] A series of values which are considered to be equivalent for the part name.
|
||||
# Each entry is a list of equivalen names. Example: ['c', 'c_small', 'cap' ]
|
||||
# will ensure the equivalent capacitor symbols can be grouped together.
|
||||
|
|
@ -709,9 +709,9 @@ outputs:
|
|||
# [list(dict)|list(string)] which columns are included in the output
|
||||
columns:
|
||||
# [string=''] [Ref,Val,Package,PosX,PosY,Rot,Side] Internal name
|
||||
- id: ''
|
||||
- id: 'Ref'
|
||||
# [string=''] Name to use in the outut file. The id is used when empty
|
||||
name: ''
|
||||
name: 'Reference'
|
||||
# [string|list(string)=''] Name of the filter to mark components as not fitted.
|
||||
# A short-cut to use for simple cases where a variant is an overkill
|
||||
dnf_filter: ''
|
||||
|
|
|
|||
|
|
@ -355,7 +355,11 @@ def print_example_options(f, cls, name, indent, po, is_list=False):
|
|||
break
|
||||
hl = ' '*i+hl[i:]
|
||||
f.write(ind_str+'# '+hl+'\n')
|
||||
val = getattr(obj, k)
|
||||
example_attr = '_'+k+'_example'
|
||||
if hasattr(obj, example_attr):
|
||||
val = getattr(obj, example_attr)
|
||||
else:
|
||||
val = getattr(obj, k)
|
||||
if isinstance(val, str):
|
||||
val = "'{}'".format(val)
|
||||
elif isinstance(val, bool):
|
||||
|
|
|
|||
|
|
@ -46,6 +46,8 @@ class BoMColumns(Optionable):
|
|||
""" Name to display in the header. The field is used when empty """
|
||||
self.join = Optionable
|
||||
""" [list(string)|string=''] List of fields to join to this column """
|
||||
self._field_example = 'Row'
|
||||
self._name_example = 'Line'
|
||||
|
||||
def config(self):
|
||||
super().config()
|
||||
|
|
@ -177,6 +179,13 @@ class GroupFields(Optionable):
|
|||
super().__init__()
|
||||
|
||||
|
||||
class NoConflict(Optionable):
|
||||
_default = "['Config', 'Part']"
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
|
||||
|
||||
class BoMOptions(BaseOptions):
|
||||
def __init__(self):
|
||||
with document:
|
||||
|
|
@ -189,7 +198,7 @@ class BoMOptions(BaseOptions):
|
|||
""" filename for the output (%i=bom)"""
|
||||
self.format = ''
|
||||
""" [HTML,CSV,TXT,TSV,XML,XLSX] format for the BoM.
|
||||
If empty defaults to CSV or a guess according to the options. """
|
||||
Defaults to CSV or a guess according to the options. """
|
||||
# Equivalent to KiBoM INI:
|
||||
self.ignore_dnf = True
|
||||
""" Exclude DNF (Do Not Fit) components """
|
||||
|
|
@ -243,10 +252,11 @@ class BoMOptions(BaseOptions):
|
|||
- ['sw', 'switch']
|
||||
- ['zener', 'zenersmall']
|
||||
- ['d', 'diode', 'd_small'] """
|
||||
self.no_conflict = Optionable
|
||||
self.no_conflict = NoConflict
|
||||
""" [list(string)] List of fields where we tolerate conflicts.
|
||||
Use it to avoid undesired warnings.
|
||||
By default the field indicated in `fit_field` and the field `part` are excluded """
|
||||
self._format_example = 'CSV'
|
||||
super().__init__()
|
||||
|
||||
@staticmethod
|
||||
|
|
@ -254,6 +264,7 @@ class BoMOptions(BaseOptions):
|
|||
""" Create a list of valid columns """
|
||||
if GS.sch:
|
||||
return GS.sch.get_field_names(ColumnList.COLUMNS_DEFAULT)
|
||||
return ColumnList.COLUMNS_DEFAULT
|
||||
|
||||
def _guess_format(self):
|
||||
""" Figure out the format """
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ from .kiplot import (check_script)
|
|||
from .gs import (GS)
|
||||
from .optionable import Optionable, BaseOptions
|
||||
from .error import KiPlotConfigurationError
|
||||
from .bom.columnlist import ColumnList
|
||||
from .macros import macros, document, output_class # noqa: F401
|
||||
from . import log
|
||||
|
||||
|
|
@ -51,6 +52,8 @@ class KiBoMColumns(Optionable):
|
|||
""" Name to display in the header. The field is used when empty """
|
||||
self.join = Optionable
|
||||
""" [list(string)|string=''] List of fields to join to this column """ # pragma: no cover
|
||||
self._field_example = 'Row'
|
||||
self._name_example = 'Line'
|
||||
|
||||
def config(self):
|
||||
super().config()
|
||||
|
|
@ -175,6 +178,8 @@ class KiBoMConfig(Optionable):
|
|||
@staticmethod
|
||||
def _get_columns():
|
||||
""" Create a list of valid columns """
|
||||
if not GS.sch:
|
||||
return ColumnList.COLUMNS_DEFAULT
|
||||
check_script(CMD_KIBOM, URL_KIBOM, '1.8.0')
|
||||
config = None
|
||||
csv = None
|
||||
|
|
|
|||
|
|
@ -41,6 +41,8 @@ class PosColumns(Optionable):
|
|||
""" [Ref,Val,Package,PosX,PosY,Rot,Side] Internal name """
|
||||
self.name = ''
|
||||
""" Name to use in the outut file. The id is used when empty """
|
||||
self._id_example = 'Ref'
|
||||
self._name_example = 'Reference'
|
||||
|
||||
def config(self):
|
||||
super().config()
|
||||
|
|
|
|||
Loading…
Reference in New Issue