Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix KiCAD8 var names #209

Merged
merged 1 commit into from
Apr 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/skidl/tools/kicad8/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ def default_lib_paths():

# Add the location of the default KiCad part libraries.
try:
paths.append(os.environ["KICAD7_SYMBOL_DIR"])
paths.append(os.environ["KICAD8_SYMBOL_DIR"])
except KeyError:
active_logger.warning(
"KICAD7_SYMBOL_DIR environment variable is missing, so the default KiCad symbol libraries won't be searched."
"KICAD8_SYMBOL_DIR environment variable is missing, so the default KiCad symbol libraries won't be searched."
)

return paths
Expand Down Expand Up @@ -88,11 +88,11 @@ def load_sch_lib(lib, filename=None, lib_search_paths_=None, lib_section=None):
lib_section: Only used for SPICE simulations.
"""

from skidl import Part, KICAD7
from skidl import Part, KICAD8
from skidl.tools import lib_suffixes

# Try to open the file using allowable suffixes for the versions of KiCAD.
suffixes = lib_suffixes[KICAD7]
suffixes = lib_suffixes[KICAD8]
base, suffix = os.path.splitext(filename)
if suffix:
# If an explicit file extension was given, use it instead of tool lib default extensions.
Expand Down Expand Up @@ -179,7 +179,7 @@ def load_sch_lib(lib, filename=None, lib_search_paths_=None, lib_section=None):
lib.add_parts(
Part(
part_defn=part_defn, # A list of lists that define the part.
tool=KICAD7,
tool=KICAD8,
dest=LIBRARY,
filename=filename,
name=part_name,
Expand Down Expand Up @@ -332,7 +332,7 @@ def parse_pins(symbol, unit_id):

# Return true if the symbol had pins.
return bool(symbol_pins)

def parse_draw_cmds(symbol):
'''Return a list of graphic drawing commands contained in the symbol.'''
return [
Expand All @@ -341,7 +341,7 @@ def parse_draw_cmds(symbol):
if item[0].value().lower()
in ("arc", "bezier", "circle", "pin", "polyline", "rectangle", "text")
]

# Parse top-level pins. (Pins in any units are parsed later.)
parse_pins(part.part_defn, unit_id="main")

Expand Down
8 changes: 7 additions & 1 deletion tests/unit_tests/test_cmds.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import pytest

from skidl import search, set_default_tool, KICAD, KICAD6, KICAD7
from skidl import search, set_default_tool, KICAD, KICAD6, KICAD7, KICAD8

from .setup_teardown import setup_function, teardown_function

Expand All @@ -26,3 +26,9 @@ def test_search_3(capfd):
search("ESP32") # Should find 6 matches in RF_Module.kicad_sym.
out, err = capfd.readouterr()
assert out.count("RF_Module.kicad_sym:") == 6

def test_search_4(capfd):
set_default_tool(KICAD8)
search("ESP32") # Should find 6 matches in RF_Module.kicad_sym.
out, err = capfd.readouterr()
assert out.count("RF_Module.kicad_sym:") == 6
5 changes: 3 additions & 2 deletions tests/unit_tests/test_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
KICAD,
KICAD6,
KICAD7,
KICAD8,
SKIDL,
TEMPLATE,
Part,
Expand All @@ -31,7 +32,7 @@
def test_missing_lib():
# Sometimes, loading a part from a non-existent library doesn't throw an
# exception until the second time it's tried. This detects that error.

# Don't allow searching backup lib that might exist from previous tests.
SchLib.reset()
skidl.config.query_backup_lib=False
Expand Down Expand Up @@ -285,4 +286,4 @@ def test_lib_kicad6_repository():
lib_4xxx = SchLib(lib_name, tool=KICAD6)
print("# of parts in {} = {}".format(lib_name, len(lib_4xxx.parts)))
for part in lib_4xxx.parts:
check_lib_part(part)
check_lib_part(part)