Added some abstraction for the KiCad project file extension.
This commit is contained in:
parent
d989857ac7
commit
46378b992b
|
|
@ -257,6 +257,7 @@ def detect_kicad():
|
|||
# So we just patch it, as we patch the name of the binaries
|
||||
GS.kicad_conf_path = GS.kicad_conf_path.replace('/kicad/', '/kicadnightly/')
|
||||
GS.kicad_share_path = GS.kicad_share_path.replace('/kicad/', '/kicadnightly/')
|
||||
GS.pro_ext = '.kicad_pro'
|
||||
else:
|
||||
# Bug in KiCad (#6989), prints to stderr:
|
||||
# `../src/common/stdpbase.cpp(62): assert "traits" failed in Get(test_dir): create wxApp before calling this`
|
||||
|
|
@ -264,6 +265,7 @@ def detect_kicad():
|
|||
# So we temporarily supress stderr
|
||||
with hide_stderr():
|
||||
GS.kicad_conf_path = pcbnew.GetKicadConfigPath()
|
||||
GS.pro_ext = '.pro'
|
||||
# Dirs to look for plugins
|
||||
GS.kicad_plugins_dirs = []
|
||||
# /usr/share/kicad/*
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ class GS(object):
|
|||
kicad_conf_path = None
|
||||
kicad_share_path = None
|
||||
kicad_plugins_dirs = []
|
||||
pro_ext = '.pro'
|
||||
# KiCad version: major*1e6+minor*1e3+patch
|
||||
kicad_version_n = 0
|
||||
kicad_version_major = 0
|
||||
|
|
|
|||
|
|
@ -172,7 +172,7 @@ class Base3DOptions(VariantOptions):
|
|||
fname = f.name
|
||||
logger.debug('Storing modified PCB to `{}`'.format(fname))
|
||||
GS.board.Save(fname)
|
||||
with open(fname.replace('.kicad_pcb', '.pro'), 'wt') as f:
|
||||
with open(fname.replace('.kicad_pcb', GS.pro_ext), 'wt') as f:
|
||||
pass
|
||||
return fname
|
||||
|
||||
|
|
|
|||
|
|
@ -65,11 +65,10 @@ class PDF_Pcb_PrintOptions(VariantOptions):
|
|||
|
||||
@staticmethod
|
||||
def _copy_project(fname):
|
||||
pro_ext = '.kicad_pro' if GS.ki6() else '.pro'
|
||||
pro_name = GS.pcb_file.replace('.kicad_pcb', pro_ext)
|
||||
pro_name = GS.pcb_file.replace('.kicad_pcb', GS.pro_ext)
|
||||
if not os.path.isfile(pro_name):
|
||||
return None
|
||||
pro_copy = fname.replace('.kicad_pcb', pro_ext)
|
||||
pro_copy = fname.replace('.kicad_pcb', GS.pro_ext)
|
||||
logger.debug('Copying project `{}` to `{}`'.format(pro_name, pro_copy))
|
||||
copy2(pro_name, pro_copy)
|
||||
return pro_copy
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ logger = log.get_logger(__name__)
|
|||
|
||||
def copy_project(sch_dir):
|
||||
""" Copy the project file to the temporal dir """
|
||||
ext = '.pro'
|
||||
ext = GS.pro_ext
|
||||
source = GS.sch_no_ext+ext
|
||||
prj_file = os.path.join(sch_dir, GS.sch_basename+ext)
|
||||
if os.path.isfile(source):
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ if kicad_version >= KICAD_VERSION_5_99:
|
|||
DEF_DWGSU = 'User_Drawings'
|
||||
DEF_ECO1U = 'User_Eco1'
|
||||
DEF_ECO2U = 'User_Eco2'
|
||||
PRO_EXT = '.kicad_pro'
|
||||
else:
|
||||
BOARDS_DIR = '../board_samples/kicad_5'
|
||||
KICAD_SCH_EXT = '.sch'
|
||||
|
|
@ -63,6 +64,7 @@ else:
|
|||
REF_DIR = 'tests/reference/5_1_7'
|
||||
else:
|
||||
REF_DIR = 'tests/reference/5_1_6'
|
||||
PRO_EXT = '.pro'
|
||||
logging.debug('Detected KiCad v{}.{}.{} ({})'.format(kicad_major, kicad_minor, kicad_patch, kicad_version))
|
||||
|
||||
|
||||
|
|
@ -162,7 +164,7 @@ class TestContext(object):
|
|||
logging.debug('Removing dir')
|
||||
shutil.rmtree(self.output_dir)
|
||||
# We don't have a project, and we don't want one
|
||||
pro = os.path.join(self.get_board_dir(), self.board_name+'.pro')
|
||||
pro = os.path.join(self.get_board_dir(), self.board_name+PRO_EXT)
|
||||
if os.path.isfile(pro) and not keep_project:
|
||||
os.remove(pro)
|
||||
# We don't have a footprint cache, and we don't want one
|
||||
|
|
|
|||
Loading…
Reference in New Issue