skidl
skidl copied to clipboard
[SKiDL BUG] search_footprints results in `FileNotFoundError: [Errno 2] No such file or directory:`
Describe the bug
Search footprints, with a properly configured path doesn't work - resulting in an exception, seemingly due to improper parsing of the path in footprint_search_paths
(running on macOS)
To Reproduce Steps to reproduce the behavior:
- set
footprint_search_paths['kicad8'] = '/Applications/KiCad/KiCad.app/Contents/SharedSupport/footprints/'
- search_footprints('cap')
- FileNotFoundError: [Errno 2] No such file or directory: 'A'
Expected behavior Return a list of footprints matching "cap"
Desktop (please complete the following information):
- OS macOS 14.5
- Python version 3.12.3
- SKiDL version [e.g. 22] 1.2.3
---------------------------------------------------------------------------
FileNotFoundError Traceback (most recent call last)
Cell In[18], line 2
1 footprint_search_paths['kicad8'] = '/Applications/KiCad/KiCad.app/Contents/SharedSupport/footprints/'
----> 2 search_footprints('cap')
File /opt/homebrew/lib/python3.11/site-packages/skidl/part_query.py:379, in search_footprints(terms, tool)
374 """
375 Print a list of footprints with the regex term within their description/tags.
376 """
378 footprints = []
--> 379 for fp in search_footprints_iter(terms, tool):
380 if fp[0] == "LIB":
381 print(" " * 79, "\rSearching {} ...".format(fp[1]), sep="", end="\r")
File /opt/homebrew/lib/python3.11/site-packages/skidl/part_query.py:304, in search_footprints_iter(terms, tool)
302 footprint_cache.clear()
303 for path in skidl.footprint_search_paths[tool]:
--> 304 footprint_cache.load(path)
306 # Get the number of footprint libraries to be searched..
307 num_fp_libs = len(footprint_cache)
File /opt/homebrew/lib/python3.11/site-packages/skidl/part_query.py:268, in FootprintCache.load(self, path)
263 continue
265 # Get a list of all the footprint module files in the top-level of the library URI.
266 filenames = [
267 fn
--> 268 for fn in os.listdir(uri)
269 if os.path.isfile(os.path.join(uri, fn))
270 and fn.lower().endswith(".kicad_mod")
271 ]
273 # Create an entry in the cache for this nickname. (This will overwrite
274 # any previous nickname entry, so make sure to scan fp-lib-tables in order of
275 # increasing priority.) Each entry contains the path to the directory containing
276 # the footprint module and a dictionary of the modules keyed by the module name
277 # with an associated value containing the module file contents (which starts off
278 # as None).
279 self[nickname] = {
280 "path": uri,
281 "modules": {os.path.splitext(fn)[0]: None for fn in filenames},
282 }
FileNotFoundError: [Errno 2] No such file or directory: 'A'