#NEWLINE# def build_compatibility_closure( api , closure , restricted_versions , full_graph ) : #NEWLINE# #INDENT# ' Builds compatibility closure for references\n\n        Args:\n            api (biicode.server.reference_translator.reference_translator_service.                                                            ReferenceTranslatorService):\n                MUST implement get_dep_table and get_published_min_refs\n            references: missing references to fetch and add to closure\n    ' #NEWLINE# retrieved = References ( ) #NEWLINE# frontier = References ( ) #NEWLINE# for ( version , cell_names ) in closure . frontier . items ( ) : #NEWLINE# #INDENT# if ( version in restricted_versions ) : #NEWLINE# #INDENT# frontier [ version ] = cell_names #NEWLINE# del closure . frontier [ version ] #NEWLINE# #UNINDENT# #UNINDENT# while frontier : #NEWLINE# #INDENT# min_cells = api . get_published_min_refs ( full_graph ) #NEWLINE# missing_dict = References ( ) #NEWLINE# for ( block_version , cell_dict ) in min_cells . iteritems ( ) : #NEWLINE# #INDENT# for ( cell_name , ( ( cell_id , content_id ) , root_id , deps ) ) in cell_dict . iteritems ( ) : #NEWLINE# #INDENT# retrieved [ block_version ] . add ( cell_name ) #NEWLINE# closure . add_item ( ( cell_id , content_id ) , root_id , block_version , cell_name ) #NEWLINE# if deps : #NEWLINE# #INDENT# missing_dict [ block_version ] . update ( deps ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# for ( version , names ) in frontier . iteritems ( ) : #NEWLINE# #INDENT# broken_names = names . difference ( min_cells . get ( version , [ ] ) ) #NEWLINE# if broken_names : #NEWLINE# #INDENT# closure . broken [ version ] . update ( broken_names ) #NEWLINE# #UNINDENT# #UNINDENT# frontier = _compute_frontier ( missing_dict , restricted_versions , full_graph , retrieved , closure . frontier )