def collect_docs_for_readmes(files_to_docs):
 readmes_to_docs = defaultdict(list)
 for (file, docs) in files_to_docs.iteritems():
  readme = get_readme_path(file)
  readmes_to_docs[readme].extend(docs)
  readmes_to_docs[readme] = list(set(readmes_to_docs[readme]))
 return readmes_to_docs

def collect_docs_for_readmes ( files_to_docs ) : readmes_to_docs = defaultdict ( list ) for ( file , docs ) in files_to_docs . iteritems ( ) : readme = get_readme_path ( file ) readmes_to_docs [ readme ] . extend ( docs ) readmes_to_docs [ readme ] = list ( set ( readmes_to_docs [ readme ] ) ) return readmes_to_docs
theres a one-to-many relationship between readmes and files .