Now IBoM output file is coherent with other outputs.
The user can select the IBoM name mechanism, but the default is to use a name coherent with all the other outputs.
This commit is contained in:
parent
d48ed3b23b
commit
43b97db20c
|
|
@ -24,10 +24,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
- Default file names for:
|
||||
- pdf_pcb_print: includes the used layers
|
||||
- drill maps: uses drill instead of drl
|
||||
- dril: uses drill instead of drl, used in gbr and drl.
|
||||
- drill: uses drill instead of drl, used in gbr and drl.
|
||||
- position: no -pos in CSVs
|
||||
- step: adds -3D
|
||||
- pdf_sch_print: adds -schematic
|
||||
- IBoM: contains the project name.
|
||||
|
||||
## [0.5.0] - 2020-07-11
|
||||
### Changed
|
||||
|
|
|
|||
|
|
@ -474,10 +474,12 @@ Next time you need this list just use an alias, like this:
|
|||
%D : bom generation date.
|
||||
%T : bom generation time.
|
||||
Extension .html will be added automatically.
|
||||
Note that this name is used only when output is ''.
|
||||
- `netlist_file`: [string=''] Path to netlist or xml file.
|
||||
- `no_blacklist_virtual`: [boolean=false] Do not blacklist virtual components.
|
||||
- `no_redraw_on_drag`: [boolean=false] Do not redraw pcb on drag by default.
|
||||
- `normalize_field_case`: [boolean=false] Normalize extra field name case. E.g. 'MPN' and 'mpn' will be considered the same field.
|
||||
- `output`: [string='%f-%i.%x'] Filename for the output, use '' to use the IBoM filename (%i=ibom, %x=html).
|
||||
- `show_fabrication`: [boolean=false] Show fabrication layer by default.
|
||||
- `sort_order`: [string='C,R,L,D,U,Y,X,F,SW,A,~,HS,CNN,J,P,NT,MH'] Default sort order for components. Must contain '~' once.
|
||||
- `variant_field`: [string=''] Name of the extra field that stores board variant for component.
|
||||
|
|
|
|||
|
|
@ -240,7 +240,8 @@ outputs:
|
|||
# %d : pcb date from metadata if available, file modification date otherwise.
|
||||
# %D : bom generation date.
|
||||
# %T : bom generation time.
|
||||
# Extension .html will be added automatically
|
||||
# Extension .html will be added automatically.
|
||||
# Note that this name is used only when output is ''
|
||||
name_format: 'ibom'
|
||||
# [string=''] Path to netlist or xml file
|
||||
netlist_file: ''
|
||||
|
|
@ -250,6 +251,8 @@ outputs:
|
|||
no_redraw_on_drag: false
|
||||
# [boolean=false] Normalize extra field name case. E.g. 'MPN' and 'mpn' will be considered the same field
|
||||
normalize_field_case: false
|
||||
# [string='%f-%i.%x'] Filename for the output, use '' to use the IBoM filename (%i=ibom, %x=html)
|
||||
output: '%f-%i.%x'
|
||||
# [boolean=false] Show fabrication layer by default
|
||||
show_fabrication: false
|
||||
# [string='C,R,L,D,U,Y,X,F,SW,A,~,HS,CNN,J,P,NT,MH'] Default sort order for components. Must contain '~' once
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@ class IBoMOptions(BaseOptions):
|
|||
def __init__(self):
|
||||
super().__init__()
|
||||
with document:
|
||||
self.output = '%f-%i.%x'
|
||||
""" Filename for the output, use '' to use the IBoM filename (%i=ibom, %x=html) """
|
||||
self.dark_mode = False
|
||||
""" Default to dark mode """
|
||||
self.hide_pads = False
|
||||
|
|
@ -43,7 +45,8 @@ class IBoMOptions(BaseOptions):
|
|||
%d : pcb date from metadata if available, file modification date otherwise.
|
||||
%D : bom generation date.
|
||||
%T : bom generation time.
|
||||
Extension .html will be added automatically """
|
||||
Extension .html will be added automatically.
|
||||
Note that this name is used only when output is '' """
|
||||
self.include_tracks = False
|
||||
""" Include track/zone information in output. F.Cu and B.Cu layers only """
|
||||
self.include_nets = False
|
||||
|
|
@ -78,9 +81,15 @@ class IBoMOptions(BaseOptions):
|
|||
# Tell ibom we don't want to use the screen
|
||||
os.environ['INTERACTIVE_HTML_BOM_NO_DISPLAY'] = ''
|
||||
cmd = [CMD_IBOM, GS.pcb_file, '--dest-dir', output_dir, '--no-browser', ]
|
||||
# Solve the output name
|
||||
output = None
|
||||
if self.output:
|
||||
output = self.expand_filename(output_dir, self.output, 'ibom', 'html')
|
||||
self.name_format = 'ibom'
|
||||
cur = os.path.join(output_dir, 'ibom.html')
|
||||
# Convert attributes into options
|
||||
for k, v in self.get_attrs_gen():
|
||||
if not v:
|
||||
if not v or k == 'output':
|
||||
continue
|
||||
cmd.append(BaseOutput.attr2longopt(k)) # noqa: F821
|
||||
if not isinstance(v, bool): # must be str/(int, float)
|
||||
|
|
@ -89,12 +98,19 @@ class IBoMOptions(BaseOptions):
|
|||
logger.debug('Running: '+str(cmd))
|
||||
try:
|
||||
cmd_output = check_output(cmd, stderr=STDOUT)
|
||||
cmd_output_dec = cmd_output.decode()
|
||||
# IBoM returns 0 for this error!!!
|
||||
if 'ERROR Parsing failed' in cmd_output_dec:
|
||||
raise CalledProcessError(1, cmd, cmd_output)
|
||||
except CalledProcessError as e:
|
||||
logger.error('Failed to create BoM, error %d', e.returncode)
|
||||
if e.output:
|
||||
logger.debug('Output from command: '+e.output.decode())
|
||||
exit(BOM_ERROR)
|
||||
logger.debug('Output from command:\n'+cmd_output.decode()+'\n')
|
||||
logger.debug('Output from command:\n'+cmd_output_dec+'\n')
|
||||
if output:
|
||||
logger.debug('Renaming output file: {} -> {}'.format(cur, output))
|
||||
os.rename(cur, output)
|
||||
|
||||
|
||||
@output_class
|
||||
|
|
@ -108,4 +124,3 @@ class IBoM(BaseOutput): # noqa: F821
|
|||
with document:
|
||||
self.options = IBoMOptions
|
||||
""" [dict] Options for the `ibom` output """ # pragma: no cover
|
||||
self._sch_related = True
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
(kicad_pcb (version 20171130) (host pcbnew 5.1.5+dfsg1-2~bpo10+1))
|
||||
|
|
@ -24,7 +24,7 @@ if prev_dir not in sys.path:
|
|||
from kiplot.misc import (BOM_ERROR)
|
||||
|
||||
BOM_DIR = 'BoM'
|
||||
IBOM_OUT = 'ibom.html'
|
||||
IBOM_OUT = 'bom-ibom.html'
|
||||
|
||||
|
||||
def test_ibom():
|
||||
|
|
@ -32,7 +32,7 @@ def test_ibom():
|
|||
ctx = context.TestContext('BoM_interactive', prj, 'ibom', BOM_DIR)
|
||||
ctx.run()
|
||||
# Check all outputs are there
|
||||
# We us this format: %f_iBoM
|
||||
# We use this format: %f_iBoM
|
||||
name = os.path.join(BOM_DIR, prj+'_iBoM')
|
||||
html = name+'.html'
|
||||
ctx.expect_out_file(html)
|
||||
|
|
@ -48,7 +48,7 @@ def test_ibom_no_ops():
|
|||
|
||||
|
||||
def test_ibom_fail():
|
||||
ctx = context.TestContext('BoM_interactiveFail', 'bom_no_xml', 'ibom', BOM_DIR)
|
||||
ctx = context.TestContext('BoM_interactiveFail', 'ibom_fail', 'ibom', BOM_DIR)
|
||||
ctx.run(BOM_ERROR)
|
||||
ctx.clean_up()
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ outputs:
|
|||
bom_view: 'left-right'
|
||||
layer_view: 'FB'
|
||||
name_format: '%f_iBoM'
|
||||
output: ''
|
||||
include_tracks: false
|
||||
include_nets: false
|
||||
sort_order: 'C,R,L,D,U,Y,X,F,SW,A,~,HS,CNN,J,P,NT,MH'
|
||||
|
|
|
|||
Loading…
Reference in New Issue