def find(start_path, paths): """ Recursively look for files loaded by start_path, add them to paths. """ with open(start_path) as f: new_paths = load_file_pattern.findall(f.read()) curdir = op.dirname(start_path) new_paths = [core.find_file(p, curdir, search_dirs) for p in new_paths] # if new_paths: # print start_path, "loads the following:\n ", "\n ".join(new_paths) # else: # print start_path, "loads no files" paths.extend(new_paths) for path in new_paths: find(path, paths)
def find(start_path, paths): """ Recursively look for files loaded by start_path, add them to paths. """ with open(start_path) as f: without_comments = comment_pattern.sub("", f.read()) new_paths = include_pattern.findall(without_comments) def add_ext(path): if path[-2:] != ".g": path += ".g" return path new_paths = (add_ext(p) for p in new_paths) curdir = os.path.dirname(start_path) new_paths = [core.find_file(p, curdir, search_dirs) for p in new_paths] if new_paths: print("%s loads the following:\n %s" % (start_path, "\n ".join(new_paths))) else: print("%s loads no files" % start_path) paths.extend(new_paths) for path in new_paths: find(path, paths)