@@ -338,20 +338,24 @@ def load_config_file(cls, filepath: PathLike, **kwargs):
338
338
raise ValueError (f"only support JSON or YAML config file so far, got name { _filepath } ." )
339
339
340
340
@classmethod
341
- def load_config_files (cls , files : Union [PathLike , Sequence [PathLike ], dict ], ** kwargs ) -> dict :
341
+ def load_config_files (cls , files : Union [PathLike , Sequence [PathLike ], dict ], ** kwargs ) -> Dict :
342
342
"""
343
343
Load config files into a single config dict.
344
+ The latter config file in the list will override or add the former config file.
345
+ ``"#"`` in the config keys are interpreted as special characters to go one level
346
+ further into the nested structures.
344
347
345
348
Args:
346
349
files: path of target files to load, supported postfixes: `.json`, `.yml`, `.yaml`.
347
350
kwargs: other arguments for ``json.load`` or ```yaml.safe_load``, depends on the file format.
348
351
"""
349
352
if isinstance (files , dict ): # already a config dict
350
353
return files
351
- content = {}
354
+ parser = ConfigParser ( config = {})
352
355
for i in ensure_tuple (files ):
353
- content .update (cls .load_config_file (i , ** kwargs ))
354
- return content
356
+ for k , v in (cls .load_config_file (i , ** kwargs )).items ():
357
+ parser [k ] = v
358
+ return parser .get () # type: ignore
355
359
356
360
@classmethod
357
361
def export_config_file (cls , config : Dict , filepath : PathLike , fmt = "json" , ** kwargs ):
0 commit comments