@@ -372,6 +372,20 @@ class Config(object):
372
372
"LOWPAN_BORDER_ROUTER" , "LOWPAN_HOST" , "LOWPAN_ROUTER" , "NANOSTACK_FULL" , "THREAD_BORDER_ROUTER" , "THREAD_END_DEVICE" , "THREAD_ROUTER" , "ETHERNET_HOST"
373
373
]
374
374
375
+ @classmethod
376
+ def find_app_config (cls , top_level_dirs ):
377
+ app_config_location = None
378
+ for directory in top_level_dirs :
379
+ full_path = os .path .join (directory , cls .__mbed_app_config_name )
380
+ if os .path .isfile (full_path ):
381
+ if app_config_location is not None :
382
+ raise ConfigException ("Duplicate '%s' file in '%s' and '%s'"
383
+ % (cls .__mbed_app_config_name ,
384
+ cls .app_config_location , full_path ))
385
+ else :
386
+ app_config_location = full_path
387
+ return app_config_location
388
+
375
389
def __init__ (self , tgt , top_level_dirs = None , app_config = None ):
376
390
"""Construct a mbed configuration
377
391
@@ -391,16 +405,8 @@ def __init__(self, tgt, top_level_dirs=None, app_config=None):
391
405
"""
392
406
config_errors = []
393
407
self .app_config_location = app_config
394
- if self .app_config_location is None :
395
- for directory in top_level_dirs or []:
396
- full_path = os .path .join (directory , self .__mbed_app_config_name )
397
- if os .path .isfile (full_path ):
398
- if self .app_config_location is not None :
399
- raise ConfigException ("Duplicate '%s' file in '%s' and '%s'"
400
- % (self .__mbed_app_config_name ,
401
- self .app_config_location , full_path ))
402
- else :
403
- self .app_config_location = full_path
408
+ if self .app_config_location is None and top_level_dirs :
409
+ self .app_config_location = self .find_app_config (top_level_dirs )
404
410
try :
405
411
self .app_config_data = json_file_to_dict (self .app_config_location ) \
406
412
if self .app_config_location else {}
0 commit comments