def resolve_deps(base_dir, file_index):
def flatten(tree, index = {}):<EOL><INDENT>for include in tree.get('<STR_LIT>', []):<EOL><INDENT>fname = base_dir + "<STR_LIT:/>" + include<EOL>assert os.path.exists(fname), "<STR_LIT>" % fname<EOL>if fname not in index:<EOL><INDENT>index[fname] = read_spec(fname)<EOL>index.update(flatten(index[fname], file_index))<EOL><DEDENT><DEDENT>return index<EOL><DEDENT>for fname, contents in file_index.items():<EOL><INDENT>file_index[fname] = read_spec(fname)<EOL>file_index.update(flatten(file_index[fname], file_index))<EOL><DEDENT>return file_index<EOL>
Given a base directory and an initial set of files, retrieves
dependencies and adds them to the file_index.