<s> """<STR_LIT>""" <EOL> from __future__ import absolute_import <EOL> from __future__ import division <EOL> from __future__ import print_function <EOL> import collections <EOL> import phlcon_differential <EOL> ReviewState = collections . namedtuple ( <EOL> '<STR_LIT>' , <EOL> [ '<STR_LIT:status>' , '<STR_LIT>' ] ) <EOL> def make_from_conduit ( conduit ) : <EOL> def revision_list_status ( revision_list ) : <EOL> return phlcon_differential . query ( conduit , revision_list ) <EOL> return ReviewStateCache ( revision_list_status ) <EOL> class ReviewStateCache ( object ) : <EOL> def __init__ ( self , status_callable ) : <EOL> super ( ReviewStateCache , self ) . __init__ ( ) <EOL> self . _review_to_state = { } <EOL> self . _active_reviews = set ( ) <EOL> self . _revision_list_status_callable = status_callable <EOL> def _make_state ( self , response ) : <EOL> return ReviewState ( response . status , response . dateModified ) <EOL> def get_state ( self , review_id ) : <EOL> assert self . _revision_list_status_callable <EOL> if review_id not in self . _review_to_state : <EOL> response = self . _revision_list_status_callable ( [ review_id ] ) [ <NUM_LIT:0> ] <EOL> self . _review_to_state [ review_id ] = self . _make_state ( response ) <EOL> self . _active_reviews . add ( review_id ) <EOL> return self . _review_to_state [ review_id ] <EOL> def refresh_active_reviews ( self ) : <EOL> assert self . _revision_list_status_callable <EOL> self . _review_to_state = { } <EOL> if self . _active_reviews : <EOL> responses = self . _revision_list_status_callable ( <EOL> list ( self . _active_reviews ) ) <EOL> self . _review_to_state = { <EOL> r . id : self . _make_state ( r ) for r in responses <EOL> } <EOL> self . _active_reviews = set ( ) <EOL> @ property <EOL> def active_reviews ( self ) : <EOL> return self . _active_reviews <EOL> def merge_additional_active_reviews ( self , active_review_set ) : <EOL> self . _active_reviews . update ( active_review_set ) </s>
