33from typing import Dict
44from typing import List
55from typing import Optional
6+ from typing import Union
67
78from idpyoidc .logging import configure_logging
89from idpyoidc .util import load_config_file
@@ -38,6 +39,9 @@ def add_path_to_directory_name(directory_name, base_path):
3839
3940def add_base_path (conf : dict , base_path : str , attributes : List [str ], attribute_type : str = "file" ):
4041 for key , val in conf .items ():
42+ if not val :
43+ continue
44+
4145 if key in attributes :
4246 if attribute_type == "file" :
4347 conf [key ] = add_path_to_filename (val , base_path )
@@ -168,7 +172,7 @@ def complete_paths(self, conf: Dict, keys: List[str], default_config: Dict, base
168172
169173 def format (self , conf , base_path : str , domain : str , port : int ,
170174 file_attributes : Optional [List [str ]] = None ,
171- dir_attributes : Optional [List [str ]] = None ) -> None :
175+ dir_attributes : Optional [List [str ]] = None ) -> Union [ Dict , str ] :
172176 """
173177 Formats parts of the configuration. That includes replacing the strings {domain} and {port}
174178 with the used domain and port and making references to files and directories absolute
@@ -183,11 +187,17 @@ def format(self, conf, base_path: str, domain: str, port: int,
183187 """
184188 if isinstance (conf , dict ):
185189 if file_attributes :
186- add_base_path (conf , base_path , file_attributes , attribute_type = "file" )
190+ conf = add_base_path (conf , base_path , file_attributes , attribute_type = "file" )
187191 if dir_attributes :
188- add_base_path (conf , base_path , dir_attributes , attribute_type = "dir" )
192+ conf = add_base_path (conf , base_path , dir_attributes , attribute_type = "dir" )
189193 if isinstance (conf , dict ):
190- set_domain_and_port (conf , domain = domain , port = port )
194+ conf = set_domain_and_port (conf , domain = domain , port = port )
195+ elif isinstance (conf , list ):
196+ conf = [_conv (v , domain = domain , port = port ) for v in conf ]
197+ elif isinstance (conf , str ):
198+ conf = _conv (conf , domain , port )
199+
200+ return conf
191201
192202
193203class Configuration (Base ):
@@ -215,10 +225,24 @@ def __init__(self,
215225 self .web_conf = lower_or_upper (self .conf , "webserver" )
216226
217227 if entity_conf :
228+ skip = [ec ["path" ] for ec in entity_conf if 'path' in ec ]
229+ check = [l [0 ] for l in skip ]
230+
218231 self .extend (conf = self .conf , base_path = base_path ,
219232 domain = self .domain , port = self .port , entity_conf = entity_conf ,
220233 file_attributes = self ._file_attributes ,
221234 dir_attributes = self ._dir_attributes )
235+ for key , val in conf .items ():
236+ if key in ["logging" , "webserver" , "domain" , "port" ]:
237+ continue
238+
239+ if key in check :
240+ continue
241+
242+ setattr (self , key , val )
243+ else :
244+ for key , val in conf .items ():
245+ setattr (self , key , val )
222246
223247
224248def create_from_config_file (cls ,
0 commit comments