@@ -57,10 +57,15 @@ def __init__(self, application_name):
5757 self .config = defaultdict (dict )
5858 self ._application_name = application_name
5959
60- def loads (self , config_filenames ):
60+ def loads (self , config_filenames , toml_config_files_prefix ):
6161 for config_filename in config_filenames :
6262 if str (config_filename ).lower ().endswith ('.toml' ):
63- prefix = f"tool.{ self ._application_name } " if config_filename == 'pyproject.toml' else ''
63+ if toml_config_files_prefix :
64+ prefix = toml_config_files_prefix
65+ elif config_filename == 'pyproject.toml' :
66+ prefix = f'tool.{ self ._application_name } '
67+ else :
68+ prefix = ''
6469 toml_config = self .load_config_toml (config_filename , prefix )
6570 for section in toml_config :
6671 self .config [section ].update (toml_config [section ].items ())
@@ -161,7 +166,8 @@ class DoitMain(object):
161166 def __init__ (self , task_loader = None ,
162167 config_filenames = ('pyproject.toml' , 'doit.cfg' ),
163168 extra_config = None ,
164- application_name = 'doit' ):
169+ application_name = 'doit' ,
170+ toml_config_files_prefix = None ):
165171 """
166172 :param extra_config: dict of extra argument values (by argument name)
167173 This is parameter is only used by explicit API call.
@@ -182,7 +188,7 @@ def __init__(self, task_loader=None,
182188
183189 # combine config option from INI/TOML files and API
184190 config_in = DoitConfig (application_name )
185- config_in .loads (config_filenames )
191+ config_in .loads (config_filenames , toml_config_files_prefix = toml_config_files_prefix )
186192 for section , vals in config_in .as_dict ().items ():
187193 self .config [section ].update (vals )
188194
0 commit comments