#NEWLINE# def _get_some_state_from_cache( self , group , types ) : #NEWLINE# #INDENT# "Checks if group is in cache. See `_get_state_for_groups`\n\n        Returns 3-tuple (`state_dict`, `missing_types`, `got_all`).\n        `missing_types` is the list of types that aren't in the cache for that\n        group. `got_all` is a bool indicating if we successfully retrieved all\n        requests state from the cache, if False we need to query the DB for the\n        missing state.\n\n        Args:\n            group: The state group to lookup\n            types (list): List of 2-tuples of the form (`type`, `state_key`),\n                where a `state_key` of `None` matches all state_keys for the\n                `type`.\n        " #NEWLINE# ( is_all , state_dict_ids ) = self . _state_group_cache . get ( group ) #NEWLINE# type_to_key = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# missing_types = set ( ) #NEWLINE# for ( typ , state_key ) in types : #NEWLINE# #INDENT# if ( state_key is None ) : #NEWLINE# #INDENT# type_to_key [ typ ] = None #NEWLINE# missing_types . add ( ( typ , state_key ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( type_to_key . get ( typ , object ( ) ) is not None ) : #NEWLINE# #INDENT# type_to_key . setdefault ( typ , set ( ) ) . add ( state_key ) #NEWLINE# #UNINDENT# if ( ( typ , is_all ) not in state_dict_ids ) : #NEWLINE# #INDENT# missing_types . add ( ( typ , state_key ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# sentinel = object ( ) #NEWLINE# def include( typ , state_key ) : #NEWLINE# #INDENT# valid_state_keys = type_to_key . get ( typ , sentinel ) #NEWLINE# if ( valid_state_keys is sentinel ) : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# if ( valid_state_keys is None ) : #NEWLINE# #INDENT# return True #NEWLINE# #UNINDENT# if ( state_key in valid_state_keys ) : #NEWLINE# #INDENT# return True #NEWLINE# #UNINDENT# return False #NEWLINE# #UNINDENT# got_all = ( not ( missing_types or ( types is None ) ) ) #NEWLINE# return ( { k : v for ( k , v ) in state_dict_ids . items ( ) if include ( k [ 0 ] , k [ 1 ] ) } , missing_types , got_all )