@@ -59,6 +59,8 @@ class _InternalCF:
5959 # For internal use only; convenience interface for reading and
6060 # writing INI-style [section] key = value configuration files,
6161 # but presenting a west-style section.key = value style API.
62+ # Unlike the higher level and public "Configuration" class, there is
63+ # one _InternalCF object for each location: LOCAL, GLOBAL,...
6264
6365 @staticmethod
6466 def parse_key (dotted_name : str ):
@@ -228,8 +230,9 @@ def getfloat(
228230 '''
229231 return self ._get (lambda cf : cf .getfloat (option ), default , configfile )
230232
231- def _get (self , getter , default , configfile ):
232- for cf in self ._whence (configfile ):
233+ def _get (self , getter , default , locations : ConfigFile ):
234+ # Search requested location(s) from higher to lower precedence
235+ for cf in self ._whence (locations ):
233236 if cf is None :
234237 continue
235238 try :
@@ -239,21 +242,21 @@ def _get(self, getter, default, configfile):
239242
240243 return default
241244
242- def _whence (self , configfile ) :
243- if configfile == ConfigFile .ALL :
245+ def _whence (self , locations : ConfigFile ) -> list [ _InternalCF | None ] :
246+ if locations == ConfigFile .ALL :
244247 if self ._local is not None :
245248 return [self ._local , self ._global , self ._system ]
246249 return [self ._global , self ._system ]
247- elif configfile == ConfigFile .SYSTEM :
250+ elif locations == ConfigFile .SYSTEM :
248251 return [self ._system ]
249- elif configfile == ConfigFile .GLOBAL :
252+ elif locations == ConfigFile .GLOBAL :
250253 return [self ._global ]
251- elif configfile == ConfigFile .LOCAL :
254+ elif locations == ConfigFile .LOCAL :
252255 if self ._local is None :
253256 raise MalformedConfig ('local configuration file not found' )
254257 return [self ._local ]
255258 else :
256- raise ValueError (configfile )
259+ raise ValueError (locations )
257260
258261 def set (self , option : str , value : Any , configfile : ConfigFile = ConfigFile .LOCAL ) -> None :
259262 '''Set a configuration option's value.
0 commit comments