<s> """<STR_LIT>""" <EOL> import itertools <EOL> from openstack_dashboard . openstack . common import uuidutils <EOL> def generate_request_id ( ) : <EOL> return '<STR_LIT>' % uuidutils . generate_uuid ( ) <EOL> class RequestContext ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , auth_token = None , user = None , tenant = None , is_admin = False , <EOL> read_only = False , show_deleted = False , request_id = None ) : <EOL> self . auth_token = auth_token <EOL> self . user = user <EOL> self . tenant = tenant <EOL> self . is_admin = is_admin <EOL> self . read_only = read_only <EOL> self . show_deleted = show_deleted <EOL> if not request_id : <EOL> request_id = generate_request_id ( ) <EOL> self . request_id = request_id <EOL> def to_dict ( self ) : <EOL> return { '<STR_LIT:user>' : self . user , <EOL> '<STR_LIT>' : self . tenant , <EOL> '<STR_LIT>' : self . is_admin , <EOL> '<STR_LIT>' : self . read_only , <EOL> '<STR_LIT>' : self . show_deleted , <EOL> '<STR_LIT>' : self . auth_token , <EOL> '<STR_LIT>' : self . request_id } <EOL> def get_admin_context ( show_deleted = "<STR_LIT>" ) : <EOL> context = RequestContext ( None , <EOL> tenant = None , <EOL> is_admin = True , <EOL> show_deleted = show_deleted ) <EOL> return context <EOL> def get_context_from_function_and_args ( function , args , kwargs ) : <EOL> """<STR_LIT>""" <EOL> for arg in itertools . chain ( kwargs . values ( ) , args ) : <EOL> if isinstance ( arg , RequestContext ) : <EOL> return arg <EOL> return None </s>
