Skip to content

Commit 774893c

Browse files
committed
Add option to blacklist components with empty value
Issue #62
1 parent 91297dd commit 774893c

File tree

4 files changed

+112
-0
lines changed

4 files changed

+112
-0
lines changed

InteractiveHtmlBom/config.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class Config:
4242
component_sort_order = default_sort_order
4343
component_blacklist = []
4444
blacklist_virtual = True
45+
blacklist_empty_val = False
4546

4647
# Extra fields section
4748
netlist_file = None
@@ -85,6 +86,8 @@ def __init__(self):
8586
','.join(self.component_blacklist)))
8687
self.blacklist_virtual = f.ReadBool(
8788
'blacklist_virtual', self.blacklist_virtual)
89+
self.blacklist_empty_val = f.ReadBool(
90+
'blacklist_empty_val', self.blacklist_empty_val)
8891

8992
f.SetPath('/extra_fields')
9093
self.extra_fields = self._split(f.Read(
@@ -125,6 +128,7 @@ def save(self):
125128
f.Write('component_blacklist',
126129
','.join(self.component_blacklist))
127130
f.WriteBool('blacklist_virtual', self.blacklist_virtual)
131+
f.WriteBool('blacklist_empty_val', self.blacklist_empty_val)
128132

129133
f.SetPath('/extra_fields')
130134
f.Write('extra_fields', ','.join(self.extra_fields))
@@ -156,6 +160,8 @@ def set_from_dialog(self, dlg):
156160
self.component_blacklist = dlg.general.blacklistBox.GetItems()
157161
self.blacklist_virtual = \
158162
dlg.general.blacklistVirtualCheckbox.IsChecked()
163+
self.blacklist_empty_val = \
164+
dlg.general.blacklistEmptyValCheckbox.IsChecked()
159165

160166
# Extra fields
161167
self.netlist_file = dlg.extra.netlistFilePicker.Path
@@ -196,6 +202,7 @@ def transfer_to_dialog(self, dlg):
196202
dlg.general.componentSortOrderBox.SetItems(self.component_sort_order)
197203
dlg.general.blacklistBox.SetItems(self.component_blacklist)
198204
dlg.general.blacklistVirtualCheckbox.Value = self.blacklist_virtual
205+
dlg.general.blacklistEmptyValCheckbox.Value = self.blacklist_empty_val
199206

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

268277
# Extra fields section
269278
parser.add_argument('--netlist-file',
@@ -306,6 +315,7 @@ def set_from_args(self, args):
306315
self.component_sort_order = self._split(args.sort_order)
307316
self.component_blacklist = self._split(args.blacklist)
308317
self.blacklist_virtual = not args.no_blacklist_virtual
318+
self.blacklist_empty_val = args.blacklist_empty_val
309319

310320
# Extra
311321
self.netlist_file = args.netlist_file

InteractiveHtmlBom/dialog/dialog_base.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,9 @@ def __init__( self, parent, id = wx.ID_ANY, pos = wx.DefaultPosition, size = wx.
270270
self.blacklistVirtualCheckbox.SetValue(True)
271271
blacklistSizer.Add( self.blacklistVirtualCheckbox, 0, wx.ALL, 5 )
272272

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

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

InteractiveHtmlBom/generate_interactive_bom.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ def skip_component(m, config, extra_data, filter_layer):
6565
if ref_prefix + '*' in config.component_blacklist:
6666
return True
6767

68+
val = m.GetValue()
69+
if config.blacklist_empty_val and val in ['', '~']:
70+
return True
71+
6872
# skip components with dnp field not empty
6973
if config.dnp_field and ref in extra_data \
7074
and config.dnp_field in extra_data[ref] \

settings_dialog.fbp

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3040,6 +3040,101 @@
30403040
<event name="OnUpdateUI"></event>
30413041
</object>
30423042
</object>
3043+
<object class="sizeritem" expanded="1">
3044+
<property name="border">5</property>
3045+
<property name="flag">wxALL</property>
3046+
<property name="proportion">0</property>
3047+
<object class="wxCheckBox" expanded="1">
3048+
<property name="BottomDockable">1</property>
3049+
<property name="LeftDockable">1</property>
3050+
<property name="RightDockable">1</property>
3051+
<property name="TopDockable">1</property>
3052+
<property name="aui_layer"></property>
3053+
<property name="aui_name"></property>
3054+
<property name="aui_position"></property>
3055+
<property name="aui_row"></property>
3056+
<property name="best_size"></property>
3057+
<property name="bg"></property>
3058+
<property name="caption"></property>
3059+
<property name="caption_visible">1</property>
3060+
<property name="center_pane">0</property>
3061+
<property name="checked">0</property>
3062+
<property name="close_button">1</property>
3063+
<property name="context_help"></property>
3064+
<property name="context_menu">1</property>
3065+
<property name="default_pane">0</property>
3066+
<property name="dock">Dock</property>
3067+
<property name="dock_fixed">0</property>
3068+
<property name="docking">Left</property>
3069+
<property name="enabled">1</property>
3070+
<property name="fg"></property>
3071+
<property name="floatable">1</property>
3072+
<property name="font"></property>
3073+
<property name="gripper">0</property>
3074+
<property name="hidden">0</property>
3075+
<property name="id">wxID_ANY</property>
3076+
<property name="label">Blacklist components with empty value</property>
3077+
<property name="max_size"></property>
3078+
<property name="maximize_button">0</property>
3079+
<property name="maximum_size"></property>
3080+
<property name="min_size"></property>
3081+
<property name="minimize_button">0</property>
3082+
<property name="minimum_size"></property>
3083+
<property name="moveable">1</property>
3084+
<property name="name">blacklistEmptyValCheckbox</property>
3085+
<property name="pane_border">1</property>
3086+
<property name="pane_position"></property>
3087+
<property name="pane_size"></property>
3088+
<property name="permission">protected</property>
3089+
<property name="pin_button">1</property>
3090+
<property name="pos"></property>
3091+
<property name="resize">Resizable</property>
3092+
<property name="show">1</property>
3093+
<property name="size"></property>
3094+
<property name="style"></property>
3095+
<property name="subclass">; ; forward_declare</property>
3096+
<property name="toolbar_pane">0</property>
3097+
<property name="tooltip"></property>
3098+
<property name="validator_data_type"></property>
3099+
<property name="validator_style">wxFILTER_NONE</property>
3100+
<property name="validator_type">wxDefaultValidator</property>
3101+
<property name="validator_variable"></property>
3102+
<property name="window_extra_style"></property>
3103+
<property name="window_name"></property>
3104+
<property name="window_style"></property>
3105+
<event name="OnAux1DClick"></event>
3106+
<event name="OnAux1Down"></event>
3107+
<event name="OnAux1Up"></event>
3108+
<event name="OnAux2DClick"></event>
3109+
<event name="OnAux2Down"></event>
3110+
<event name="OnAux2Up"></event>
3111+
<event name="OnChar"></event>
3112+
<event name="OnCharHook"></event>
3113+
<event name="OnCheckBox"></event>
3114+
<event name="OnEnterWindow"></event>
3115+
<event name="OnEraseBackground"></event>
3116+
<event name="OnKeyDown"></event>
3117+
<event name="OnKeyUp"></event>
3118+
<event name="OnKillFocus"></event>
3119+
<event name="OnLeaveWindow"></event>
3120+
<event name="OnLeftDClick"></event>
3121+
<event name="OnLeftDown"></event>
3122+
<event name="OnLeftUp"></event>
3123+
<event name="OnMiddleDClick"></event>
3124+
<event name="OnMiddleDown"></event>
3125+
<event name="OnMiddleUp"></event>
3126+
<event name="OnMotion"></event>
3127+
<event name="OnMouseEvents"></event>
3128+
<event name="OnMouseWheel"></event>
3129+
<event name="OnPaint"></event>
3130+
<event name="OnRightDClick"></event>
3131+
<event name="OnRightDown"></event>
3132+
<event name="OnRightUp"></event>
3133+
<event name="OnSetFocus"></event>
3134+
<event name="OnSize"></event>
3135+
<event name="OnUpdateUI"></event>
3136+
</object>
3137+
</object>
30433138
</object>
30443139
</object>
30453140
</object>

0 commit comments

Comments
 (0)