Added support for KICAD_CONFIG_HOME defined from inside KiCad

This commit is contained in:
Salvador E. Tropea 2021-01-08 12:47:15 -03:00
parent 73a35762e6
commit 45ac28a6bf
2 changed files with 10 additions and 3 deletions

View File

@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- The multipart id to references of multipart components others than part 1.
- Internal BoM: `no_conflict` option to exclude fields from conflict detection.
- Support for KICAD_CONFIG_HOME defined from inside KiCad
## [0.9.0] - 2021-01-04
### Added

View File

@ -207,7 +207,7 @@ class KiConf(object):
def load_lib_aliases(fname):
if not os.path.isfile(fname):
return
return False
logger.debug('Loading symbols lib table `{}`'.format(fname))
with open(fname, 'rt') as f:
line = f.readline().strip()
@ -226,13 +226,19 @@ class KiConf(object):
raise KiConfError('Unknown symbol table entry', SYM_LIB_TABLE, cline, line)
line = f.readline()
cline += 1
return True
def load_all_lib_aliases():
# Load the default symbol libs table.
# This is the list of libraries enabled by the user.
loaded = False
if KiConf.config_dir:
KiConf.load_lib_aliases(os.path.join(KiConf.config_dir, SYM_LIB_TABLE))
else:
conf_dir = KiConf.config_dir
if 'KICAD_CONFIG_HOME' in KiConf.kicad_env:
conf_dir = KiConf.kicad_env['KICAD_CONFIG_HOME']
logger.debug('Redirecting symbols lib table to '+conf_dir)
loaded = KiConf.load_lib_aliases(os.path.join(conf_dir, SYM_LIB_TABLE))
if not loaded:
logger.warning(W_NODEFSYMLIB + 'Missing default symbol library table')
# No default symbol libs table, try to create one
if KiConf.sym_lib_dir: