Here is the code:
# Now create libraries for any asys Simulation Models that are present in the module
asysdir = moduleRootDir / asys_sys_tail
asys_systems = []
if asysdir.is_dir():
asys_systems = [x for x in asysdir.iterdir() if
(x.is_dir() and (x.name != '.asys_edit'))]
asyslibslist = []
for sys in asys_systems:
libname = "lib_asys_" + sys.name
lib = vu.add_library(libname)
for ext in extensions:
matches = set(item for item in sys.rglob(str("*") + str(ext)))
for match in matches:
# Check for duplications in the "rtlfiles" list
if match.parent.name == 'mentor':
logger.debug("Match to /mentor/ file!! " + str(match.absolute()))
continue
elif match.name in [item.name for item in DupList]:
logger.debug("Item in DupList! : " + str(match.name))
continue
elif match.name in GlobalExclusions:
continue
else:
logger.debug("Adding to lib " + str(libname) + " :" + str(match.absolute()))
lib.add_source_file(match.absolute())
DupList.append(match)
asyslibslist.append(lib)
# Print the DupList after each module
print_duplist(DupList)
This code starts search in a folder called 'asys_systems'. It checks what folder exist inside it and adds it into collection asys_systems. Then, it searches for files inside each folder in the asys_systems collection.
I have no experience with Python but need to change this code so to limit the recursive search. For example, we have this folder structure:
asys_system_1
sub_folder_1
sub_folder_2
I want that all the files inside asys_system_1 be searched through, and also sub_folder_2 but not sub_folder_1.
How to exclude certain sub-folder from being searched by the sys.rglob?