[Added] More information about wrong configs
When trying to use more than one YAML document for definitions See #559
This commit is contained in:
parent
4ec3b345d0
commit
c04067d603
|
|
@ -24,7 +24,7 @@ import textwrap
|
||||||
from .error import KiPlotConfigurationError, config_error
|
from .error import KiPlotConfigurationError, config_error
|
||||||
from .misc import (NO_YAML_MODULE, EXIT_BAD_ARGS, EXAMPLE_CFG, WONT_OVERWRITE, W_NOOUTPUTS, W_UNKOUT, W_NOFILTERS,
|
from .misc import (NO_YAML_MODULE, EXIT_BAD_ARGS, EXAMPLE_CFG, WONT_OVERWRITE, W_NOOUTPUTS, W_UNKOUT, W_NOFILTERS,
|
||||||
W_NOVARIANTS, W_NOGLOBALS, TRY_INSTALL_CHECK, W_NOPREFLIGHTS, W_NOGROUPS, W_NEWGROUP, error_level_to_name,
|
W_NOVARIANTS, W_NOGLOBALS, TRY_INSTALL_CHECK, W_NOPREFLIGHTS, W_NOGROUPS, W_NEWGROUP, error_level_to_name,
|
||||||
DEFAULT_ROTATIONS, DEFAULT_OFFSETS)
|
DEFAULT_ROTATIONS, DEFAULT_OFFSETS, W_EXTRADOCS)
|
||||||
from .gs import GS
|
from .gs import GS
|
||||||
from .registrable import RegOutput, RegVariant, RegFilter, RegDependency
|
from .registrable import RegOutput, RegVariant, RegFilter, RegDependency
|
||||||
from .pre_base import BasePreFlight
|
from .pre_base import BasePreFlight
|
||||||
|
|
@ -563,7 +563,7 @@ class CfgYamlReader(object):
|
||||||
raise KiPlotConfigurationError("`import` items must be strings or dicts ({})".format(str(entry)))
|
raise KiPlotConfigurationError("`import` items must be strings or dicts ({})".format(str(entry)))
|
||||||
fn, is_internal = self.check_import_file_name(dir_name, fn, is_external)
|
fn, is_internal = self.check_import_file_name(dir_name, fn, is_external)
|
||||||
fn_rel = os.path.relpath(fn)
|
fn_rel = os.path.relpath(fn)
|
||||||
# Create a new dict for definitions applying the new ones and nake it the last
|
# Create a new dict for definitions applying the new ones and make it the last
|
||||||
cur_definitions = deepcopy(collected_definitions[-1])
|
cur_definitions = deepcopy(collected_definitions[-1])
|
||||||
cur_definitions.update(local_defs)
|
cur_definitions.update(local_defs)
|
||||||
collected_definitions.append(cur_definitions)
|
collected_definitions.append(cur_definitions)
|
||||||
|
|
@ -609,13 +609,19 @@ class CfgYamlReader(object):
|
||||||
content = fstream.read()
|
content = fstream.read()
|
||||||
docs = re.split(r"^\.\.\.$", content, flags=re.M)
|
docs = re.split(r"^\.\.\.$", content, flags=re.M)
|
||||||
local_defs = None
|
local_defs = None
|
||||||
if len(docs) > 1:
|
n_docs = len(docs)
|
||||||
|
if n_docs > 1:
|
||||||
|
if n_docs > 2:
|
||||||
|
logger.warning(W_EXTRADOCS+f'found {n_docs} YAML documents, KiBot can handle just 2')
|
||||||
definitions = None
|
definitions = None
|
||||||
|
content = None
|
||||||
for doc in docs:
|
for doc in docs:
|
||||||
if re.search(r"^kibot:\s*$", doc, flags=re.M):
|
if re.search(r"^kibot:\s*$", doc, flags=re.M):
|
||||||
content = doc
|
content = doc
|
||||||
elif re.search(r"^definitions:\s*$", doc, flags=re.M):
|
elif re.search(r"^definitions:\s*$", doc, flags=re.M):
|
||||||
definitions = doc
|
definitions = doc
|
||||||
|
if content is None:
|
||||||
|
raise KiPlotConfigurationError("No `kibot` section")
|
||||||
if definitions:
|
if definitions:
|
||||||
logger.debug("Found local definitions")
|
logger.debug("Found local definitions")
|
||||||
try:
|
try:
|
||||||
|
|
@ -632,6 +638,8 @@ class CfgYamlReader(object):
|
||||||
local_defs.update(collected_definitions[-1])
|
local_defs.update(collected_definitions[-1])
|
||||||
collected_definitions[-1] = local_defs
|
collected_definitions[-1] = local_defs
|
||||||
logger.debug("- Updated definitions: "+str(collected_definitions[-1]))
|
logger.debug("- Updated definitions: "+str(collected_definitions[-1]))
|
||||||
|
else:
|
||||||
|
logger.warning(W_EXTRADOCS+f'found {n_docs} YAML documents, but no `definitions`')
|
||||||
# Apply the definitions
|
# Apply the definitions
|
||||||
if GS.cli_defines or collected_definitions[-1]:
|
if GS.cli_defines or collected_definitions[-1]:
|
||||||
logger.debug('Applying preprocessor definitions')
|
logger.debug('Applying preprocessor definitions')
|
||||||
|
|
|
||||||
|
|
@ -295,6 +295,7 @@ W_BADOFFSET = '(W136) '
|
||||||
W_BUG16418 = '(W137) '
|
W_BUG16418 = '(W137) '
|
||||||
W_NOTHCMP = '(W138) '
|
W_NOTHCMP = '(W138) '
|
||||||
W_KEEPTMP = '(W139) '
|
W_KEEPTMP = '(W139) '
|
||||||
|
W_EXTRADOCS = '(W140) '
|
||||||
# Somehow arbitrary, the colors are real, but can be different
|
# Somehow arbitrary, the colors are real, but can be different
|
||||||
PCB_MAT_COLORS = {'fr1': "937042", 'fr2': "949d70", 'fr3': "adacb4", 'fr4': "332B16", 'fr5': "6cc290"}
|
PCB_MAT_COLORS = {'fr1': "937042", 'fr2': "949d70", 'fr3': "adacb4", 'fr4': "332B16", 'fr5': "6cc290"}
|
||||||
PCB_FINISH_COLORS = {'hal': "8b898c", 'hasl': "8b898c", 'imag': "8b898c", 'enig': "cfb96e", 'enepig': "cfb96e",
|
PCB_FINISH_COLORS = {'hal': "8b898c", 'hasl': "8b898c", 'imag': "8b898c", 'enig': "cfb96e", 'enepig': "cfb96e",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue