diff --git a/setup.py b/setup.py index 5fa6ef0d..b2853488 100644 --- a/setup.py +++ b/setup.py @@ -52,12 +52,8 @@ # packages=['skidl',], packages=setuptools.find_packages(exclude=["tests"]), entry_points={ - "console_scripts": [ - "netlist_to_skidl = skidl.netlist_to_skidl_main:main", - ], - "gui_scripts": [ - "zyc = skidl.search_gui.skidl_part_footprint_search:main", - ], + "console_scripts": ["netlist_to_skidl = skidl.netlist_to_skidl_main:main"], + "gui_scripts": ["zyc = skidl.search_gui.skidl_part_footprint_search:main"], }, package_dir={"skidl": "skidl"}, include_package_data=True, diff --git a/skidl/part_query.py b/skidl/part_query.py index 70e82073..d3485e69 100644 --- a/skidl/part_query.py +++ b/skidl/part_query.py @@ -57,7 +57,12 @@ def parse_search_terms(terms): non-white chars to prevent the initial portion of a quoted string from being gathered up as a non-white character sequence. """ - return re.sub(r"((\".*?\")|(\S+))\s*", r"(?=.*(\1))", terms.strip().rstrip()).replace('"', "") + ".*" + return ( + re.sub(r"((\".*?\")|(\S+))\s*", r"(?=.*(\1))", terms.strip().rstrip()).replace( + '"', "" + ) + + ".*" + ) def search_parts_iter(terms, tool=None): @@ -333,7 +338,9 @@ def search_footprints_iter(terms, tool=None): search_text = "\n".join([search_text, line]) # Search the string for a match with the search terms. - if fullmatch(terms, search_text, flags=re.IGNORECASE | re.MULTILINE | re.DOTALL): + if fullmatch( + terms, search_text, flags=re.IGNORECASE | re.MULTILINE | re.DOTALL + ): yield "MODULE", fp_lib, module_text, module_name # At the end, all modules have been scanned and the footprint cache is valid. diff --git a/skidl/search_gui/common.py b/skidl/search_gui/common.py index 7762a883..7c5f29ac 100644 --- a/skidl/search_gui/common.py +++ b/skidl/search_gui/common.py @@ -36,9 +36,7 @@ import wx.lib.newevent MINIMUM_PANE_SIZE = 300 -BTN_SIZE = (50, -1) SPACING = 5 -TEXT_BOX_WIDTH = 200 CELL_BCK_COLOUR = wx.Colour(255, 255, 255) # Table cell background color. TITLE_BCK_COLOUR = wx.Colour(128, 128, 128) TITLE_FG_COLOUR = wx.Colour(200, 200, 200) @@ -170,10 +168,7 @@ def __init__(self, parent, label): ) self.desc = wx.TextCtrl( - self, - # size=(TEXT_BOX_WIDTH, 60), - size=(10000, 60), - style=wx.TE_READONLY | wx.TE_MULTILINE | wx.TE_NO_VSCROLL, + self, size=(10000, 60), style=wx.TE_READONLY | wx.TE_MULTILINE ) vbox.Add(self.desc, proportion=0, flag=wx.ALL, border=SPACING) diff --git a/skidl/search_gui/skidl_footprint_search.py b/skidl/search_gui/skidl_footprint_search.py index 76048251..31370035 100644 --- a/skidl/search_gui/skidl_footprint_search.py +++ b/skidl/search_gui/skidl_footprint_search.py @@ -271,15 +271,13 @@ def InitSearchPanel(self, parent): search_panel.SetSizer(vbox) # Text box for footprint search string. - self.search_text = wx.TextCtrl( - search_panel, size=(TEXT_BOX_WIDTH, -1), style=wx.TE_PROCESS_ENTER - ) + self.search_text = wx.TextCtrl(search_panel, style=wx.TE_PROCESS_ENTER) self.search_text.Bind(wx.EVT_TEXT_ENTER, self.OnSearch) tip = wx.ToolTip("Enter text or regular expression to select footprints.") self.search_text.SetToolTip(tip) # Button to initiate search for footprints containing search string. - search_btn = wx.Button(search_panel, label="Search", size=BTN_SIZE) + search_btn = wx.Button(search_panel, label="Search") search_btn.Bind(wx.EVT_BUTTON, self.OnSearch) tip = wx.ToolTip( "Search for footprints containing the text or regular expression." @@ -295,7 +293,7 @@ def InitSearchPanel(self, parent): self.found_footprints.Bind(wx.grid.EVT_GRID_CELL_LEFT_DCLICK, self.OnCopy) # Button to copy selected footprint to clipboard. - copy_btn = wx.Button(search_panel, label="Copy", size=BTN_SIZE) + copy_btn = wx.Button(search_panel, label="Copy") copy_btn.Bind(wx.EVT_BUTTON, self.OnCopy) tip = wx.ToolTip("Copy the selected footprint to the clipboard.") copy_btn.SetToolTip(tip) @@ -428,10 +426,10 @@ def OnSelectCell(self, event): # Ths is a null footprint that just paints an "X" (cross) when there's no valid footprint. null_module_text = [ - "(module NULL", - "(fp_line (start 0.0 0.0) (end 1.0 1.0) (layer F.Fab) (width 0.01))", - "(fp_line (start 1.0 0.0) (end 0.0 1.0) (layer F.Fab) (width 0.01))", - ")", + "(module NULL", + "(fp_line (start 0.0 0.0) (end 1.0 1.0) (layer F.Fab) (width 0.01))", + "(fp_line (start 1.0 0.0) (end 0.0 1.0) (layer F.Fab) (width 0.01))", + ")", ] # Get the selected row in the lib/footprint table and translate it to the row in the data table. @@ -439,7 +437,6 @@ def OnSelectCell(self, event): self.found_footprints.SelectRow(event.GetRow()) row = self.found_footprints.GetDataRowIndex(event.GetRow()) - # Get the text describing the footprint structure. try: module_text = self.footprints[row][1] diff --git a/skidl/search_gui/skidl_part_search.py b/skidl/search_gui/skidl_part_search.py index 2eb86793..789e2d94 100644 --- a/skidl/search_gui/skidl_part_search.py +++ b/skidl/search_gui/skidl_part_search.py @@ -220,15 +220,13 @@ def InitSearchPanel(self, parent): search_panel.SetSizer(vbox) # Text box for part search string. - self.search_text = wx.TextCtrl( - search_panel, size=(TEXT_BOX_WIDTH, -1), style=wx.TE_PROCESS_ENTER - ) + self.search_text = wx.TextCtrl(search_panel, style=wx.TE_PROCESS_ENTER) self.search_text.Bind(wx.EVT_TEXT_ENTER, self.OnSearch) tip = wx.ToolTip("Enter text or regular expression to select parts.") self.search_text.SetToolTip(tip) # Button to initiate search for parts containing search string. - search_btn = wx.Button(search_panel, label="Search", size=BTN_SIZE) + search_btn = wx.Button(search_panel, label="Search") search_btn.Bind(wx.EVT_BUTTON, self.OnSearch) tip = wx.ToolTip("Search for parts containing the text or regular expression.") search_btn.SetToolTip(tip) @@ -240,7 +238,7 @@ def InitSearchPanel(self, parent): self.found_parts.Bind(wx.grid.EVT_GRID_CELL_LEFT_DCLICK, self.OnCopy) # Button to copy selected lib/part to clipboard. - copy_btn = wx.Button(search_panel, label="Copy", size=BTN_SIZE) + copy_btn = wx.Button(search_panel, label="Copy") copy_btn.Bind(wx.EVT_BUTTON, self.OnCopy) tip = wx.ToolTip("Copy the selected part to the clipboard.") copy_btn.SetToolTip(tip) @@ -260,7 +258,9 @@ def InitSearchPanel(self, parent): [ search_btn, (self.search_text, 1, wx.EXPAND), - stack_it(copy_btn, self.template_ckbx), # Copy & template buttons stacked together. + stack_it( + copy_btn, self.template_ckbx + ), # Copy & template buttons stacked together. (self.found_parts, 1, wx.EXPAND), ] ) @@ -429,7 +429,7 @@ def OnSelectCell(self, event): fp_srch_terms = re.sub("[*?]", ".\g<0>", fp_srch_terms) # Use the number of pins in the part to refine the search. num_pins = len(part.pins) - fp_srch_terms = " ".join((fp_srch_terms, '^#pads={}$'.format(num_pins))) + fp_srch_terms = " ".join((fp_srch_terms, "^#pads={}$".format(num_pins))) # Send the string of search terms to the footprint search panel. evt = SendSearchTermsEvent(search_terms=fp_srch_terms) diff --git a/skidl/skidl.py b/skidl/skidl.py index e060884c..6236e39f 100644 --- a/skidl/skidl.py +++ b/skidl/skidl.py @@ -76,6 +76,7 @@ def store(self, dir="."): with open(path, "w") as cfg_fp: json.dump(self, cfg_fp, indent=4) + def get_kicad_lib_tbl_dir(): """Get the path to where the global fp-lib-table file is found.""" diff --git a/skidl/tools/kicad.py b/skidl/tools/kicad.py index 59b5e43d..d22a3ba7 100644 --- a/skidl/tools/kicad.py +++ b/skidl/tools/kicad.py @@ -116,7 +116,7 @@ def _load_sch_lib_(self, filename=None, lib_search_paths_=None): keywords="", datasheet="", description="", - search_text = "", + search_text="", ) )