Skip to content

Commit

Permalink
Join footprint search text with newlines so ^ and $ can be used to fi…
Browse files Browse the repository at this point in the history
…nd line beginnings and endings.

* Selecting a part concatenates fplist and number of pads as an initial search string for a footprint.
  • Loading branch information
Dave Vandenbout committed Sep 30, 2019
1 parent 39955b5 commit 623c515
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions skidl/part_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,17 +323,17 @@ def search_footprints_iter(terms, tool=None):
num_pads = len(
set(re.findall("\(\s*pad\s+([^\s)]+)", " ".join(module_text)))
)
num_pads_str = "#pads={} ".format(num_pads)
num_pads_str = "#pads={}".format(num_pads)

# Create a string with the module name, library name, number of pads,
# description and tags.
search_text = " ".join([num_pads_str, fp_lib, module_name])
search_text = "\n".join([num_pads_str, fp_lib, module_name])
for line in module_text:
if "(descr " in line or "(tags " in line:
search_text += " ".join([search_text, line])
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):
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.
Expand Down
8 changes: 4 additions & 4 deletions skidl/search_gui/skidl_part_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,10 +427,10 @@ def OnSelectCell(self, event):
# First, search for any of the footprints in the fplist of the part.
fp_srch_terms = "|".join(part.fplist)
fp_srch_terms = re.sub("[*?]", ".\g<0>", fp_srch_terms)
# If no footprints in fplist, then use the number of pins in the part.
if not part.fplist:
num_pins = len(part.pins)
fp_srch_terms = '"#pads={} "'.format(num_pins)
# 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)))

# Send the string of search terms to the footprint search panel.
evt = SendSearchTermsEvent(search_terms=fp_srch_terms)
wx.PostEvent(wx.FindWindowById(FOOTPRINT_PANEL_ID), evt)
Expand Down

0 comments on commit 623c515

Please sign in to comment.