Skip to content

Commit

Permalink
Add option to blacklist components with empty value
Browse files Browse the repository at this point in the history
Issue #62
  • Loading branch information
qu1ck committed Dec 10, 2018
1 parent 91297dd commit 774893c
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 0 deletions.
10 changes: 10 additions & 0 deletions InteractiveHtmlBom/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class Config:
component_sort_order = default_sort_order
component_blacklist = []
blacklist_virtual = True
blacklist_empty_val = False

# Extra fields section
netlist_file = None
Expand Down Expand Up @@ -85,6 +86,8 @@ def __init__(self):
','.join(self.component_blacklist)))
self.blacklist_virtual = f.ReadBool(
'blacklist_virtual', self.blacklist_virtual)
self.blacklist_empty_val = f.ReadBool(
'blacklist_empty_val', self.blacklist_empty_val)

f.SetPath('/extra_fields')
self.extra_fields = self._split(f.Read(
Expand Down Expand Up @@ -125,6 +128,7 @@ def save(self):
f.Write('component_blacklist',
','.join(self.component_blacklist))
f.WriteBool('blacklist_virtual', self.blacklist_virtual)
f.WriteBool('blacklist_empty_val', self.blacklist_empty_val)

f.SetPath('/extra_fields')
f.Write('extra_fields', ','.join(self.extra_fields))
Expand Down Expand Up @@ -156,6 +160,8 @@ def set_from_dialog(self, dlg):
self.component_blacklist = dlg.general.blacklistBox.GetItems()
self.blacklist_virtual = \
dlg.general.blacklistVirtualCheckbox.IsChecked()
self.blacklist_empty_val = \
dlg.general.blacklistEmptyValCheckbox.IsChecked()

# Extra fields
self.netlist_file = dlg.extra.netlistFilePicker.Path
Expand Down Expand Up @@ -196,6 +202,7 @@ def transfer_to_dialog(self, dlg):
dlg.general.componentSortOrderBox.SetItems(self.component_sort_order)
dlg.general.blacklistBox.SetItems(self.component_blacklist)
dlg.general.blacklistVirtualCheckbox.Value = self.blacklist_virtual
dlg.general.blacklistEmptyValCheckbox.Value = self.blacklist_empty_val

# Extra fields
dlg.extra.netlistFilePicker.SetInitialDirectory(
Expand Down Expand Up @@ -264,6 +271,8 @@ def add_options(self, parser):
'components or prefixes with *. E.g. "X1,MH*"')
parser.add_argument('--no-blacklist-virtual', action='store_true',
help='Do not blacklist virtual components.')
parser.add_argument('--blacklist-empty-val', action='store_true',
help='Blacklist components with empty value.')

# Extra fields section
parser.add_argument('--netlist-file',
Expand Down Expand Up @@ -306,6 +315,7 @@ def set_from_args(self, args):
self.component_sort_order = self._split(args.sort_order)
self.component_blacklist = self._split(args.blacklist)
self.blacklist_virtual = not args.no_blacklist_virtual
self.blacklist_empty_val = args.blacklist_empty_val

# Extra
self.netlist_file = args.netlist_file
Expand Down
3 changes: 3 additions & 0 deletions InteractiveHtmlBom/dialog/dialog_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,9 @@ def __init__( self, parent, id = wx.ID_ANY, pos = wx.DefaultPosition, size = wx.
self.blacklistVirtualCheckbox.SetValue(True)
blacklistSizer.Add( self.blacklistVirtualCheckbox, 0, wx.ALL, 5 )

self.blacklistEmptyValCheckbox = wx.CheckBox( blacklistSizer.GetStaticBox(), wx.ID_ANY, u"Blacklist components with empty value", wx.DefaultPosition, wx.DefaultSize, 0 )
blacklistSizer.Add( self.blacklistEmptyValCheckbox, 0, wx.ALL, 5 )


bSizer32.Add( blacklistSizer, 1, wx.ALL|wx.EXPAND|wx.TOP, 5 )

Expand Down
4 changes: 4 additions & 0 deletions InteractiveHtmlBom/generate_interactive_bom.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ def skip_component(m, config, extra_data, filter_layer):
if ref_prefix + '*' in config.component_blacklist:
return True

val = m.GetValue()
if config.blacklist_empty_val and val in ['', '~']:
return True

# skip components with dnp field not empty
if config.dnp_field and ref in extra_data \
and config.dnp_field in extra_data[ref] \
Expand Down
95 changes: 95 additions & 0 deletions settings_dialog.fbp
Original file line number Diff line number Diff line change
Expand Up @@ -3040,6 +3040,101 @@
<event name="OnUpdateUI"></event>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL</property>
<property name="proportion">0</property>
<object class="wxCheckBox" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="checked">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Blacklist components with empty value</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">blacklistEmptyValCheckbox</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnAux1DClick"></event>
<event name="OnAux1Down"></event>
<event name="OnAux1Up"></event>
<event name="OnAux2DClick"></event>
<event name="OnAux2Down"></event>
<event name="OnAux2Up"></event>
<event name="OnChar"></event>
<event name="OnCharHook"></event>
<event name="OnCheckBox"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
</object>
</object>
</object>
</object>
</object>
Expand Down

0 comments on commit 774893c

Please sign in to comment.