@@ -383,9 +383,18 @@ def scan_resources(self, path, exclude_paths=None):
383
383
"""
384
384
for root , dirs , files in walk (path , followlinks = True ):
385
385
# Remove ignored directories
386
+ # Check if folder contains .mbedignore
387
+ if ".mbedignore" in files :
388
+ with open (join (root ,".mbedignore" ), "r" ) as f :
389
+ lines = f .readlines ()
390
+ lines = [l .strip () for l in lines ] # Strip whitespaces
391
+ lines = [l for l in lines if l != "" ] # Strip empty lines
392
+ lines = [l for l in lines if not re .match ("^#" ,l )] # Strip comment lines
393
+ # Append root path to glob patterns
394
+ # and append patterns to ignorepatterns
395
+ self .ignorepatterns .extend ([join (root ,line .strip ()) for line in lines ])
386
396
for d in copy (dirs ):
387
397
dir_path = join (root , d )
388
-
389
398
if d == '.hg' :
390
399
resources .repo_dirs .append (dir_path )
391
400
resources .repo_files .extend (self .scan_repository (dir_path ))
@@ -396,18 +405,6 @@ def scan_resources(self, path, exclude_paths=None):
396
405
(d == 'TESTS' )):
397
406
dirs .remove (d )
398
407
399
- # Check if folder contains .mbedignore
400
- try :
401
- with open (join (dir_path ,".mbedignore" ), "r" ) as f :
402
- lines = f .readlines ()
403
- lines = [l .strip () for l in lines ] # Strip whitespaces
404
- lines = [l for l in lines if l != "" ] # Strip empty lines
405
- lines = [l for l in lines if not re .match ("^#" ,l )] # Strip comment lines
406
- # Append root path to glob patterns
407
- # and append patterns to ignorepatterns
408
- self .ignorepatterns .extend ([join (dir_path ,line .strip ()) for line in lines ])
409
- except IOError :
410
- pass
411
408
412
409
# Remove dirs that already match the ignorepatterns
413
410
# to avoid travelling into them and to prevent them
0 commit comments