5454#from textwrap import dedent
5555
5656# For type-hinting
57- from typing import List , Set , Dict , Tuple , Optional , Iterable
57+ # from typing import List, Set, Dict, Tuple, Optional, Iterable
5858
5959try : # pragma: no cover
6060 # @final decorator, requires Python 3.8.x
6767import shlex
6868
6969from configparserenhanced import *
70+ from configparserenhanced import TypedProperty
7071
7172from .SetProgramOptions import SetProgramOptions
7273from .SetProgramOptions import ExpandVarsInText
8081# ===============================
8182
8283
83-
8484class ExpandVarsInTextCMake (ExpandVarsInText ):
8585 """
8686 Extends ``ExpandVarsInText`` class to add in support for a ``CMAKE`` generator.
8787 """
8888
89+ # Typed Property `_bashgen_unhandled_cmake_var_eventtype`:
90+ # sets the exception_control_event level for when an unresolved
91+ # `CMake` var is encountered by the BASH generator.
92+ _bashgen_unhandled_cmake_var_eventtype = \
93+ TypedProperty .typed_property ("_bashgen_unhandled_cmake_var_eventtype" ,
94+ expected_type = str ,
95+ default = "MINOR" ,
96+ internal_type = str )
97+
8998 def __init__ (self ):
9099 self .exception_control_level = 3
91100
@@ -112,9 +121,10 @@ def _fieldhandler_BASH_CMAKE(self, field):
112121 else :
113122 # If self.exception_control_level is >= 4 then we'll raise the error
114123 # instead of sending a warning.
115- msg = f"Unhandled variable expansion for `{ field .varname } ` in a BASH file."
124+ # Change this to `CATASTROPHIC` to always throw the error.
125+ msg = f"Unresolved variable expansion for `{ field .varname } ` in a BASH file."
116126 msg += " CMake variables are only valid in a CMake fragment file."
117- self .exception_control_event ("MINOR" , ValueError , msg )
127+ self .exception_control_event (self . _bashgen_unhandled_cmake_var_eventtype , ValueError , msg )
118128 output = ""
119129 return output
120130
@@ -331,7 +341,7 @@ def handler_initialize(self, section_name: str, handler_parameters) -> int:
331341 # ---------------------------------------------------------------
332342
333343 @ConfigParserEnhanced .operation_handler
334- def _handler_opt_set_cmake_var (self , section_name , handler_parameters ) -> int :
344+ def _handler_opt_set_cmake_var (self , section_name : str , handler_parameters ) -> int :
335345 """Handler for ``opt-set-cmake-var``
336346
337347 Called By: ``configparserenhanced.ConfigParserEnhanced`` parser.
0 commit comments