<s> from functools import wraps <EOL> def csp_exempt ( f ) : <EOL> @ wraps ( f ) <EOL> def _wrapped ( * a , ** kw ) : <EOL> r = f ( * a , ** kw ) <EOL> r . _csp_exempt = True <EOL> return r <EOL> return _wrapped <EOL> def csp_update ( ** kwargs ) : <EOL> update = dict ( ( k . lower ( ) . replace ( '<STR_LIT:_>' , '<STR_LIT:->' ) , v ) for k , v in kwargs . items ( ) ) <EOL> def decorator ( f ) : <EOL> @ wraps ( f ) <EOL> def _wrapped ( * a , ** kw ) : <EOL> r = f ( * a , ** kw ) <EOL> r . _csp_update = update <EOL> return r <EOL> return _wrapped <EOL> return decorator <EOL> def csp_replace ( ** kwargs ) : <EOL> replace = dict ( ( k . lower ( ) . replace ( '<STR_LIT:_>' , '<STR_LIT:->' ) , v ) for k , v in kwargs . items ( ) ) <EOL> def decorator ( f ) : <EOL> @ wraps ( f ) <EOL> def _wrapped ( * a , ** kw ) : <EOL> r = f ( * a , ** kw ) <EOL> r . _csp_replace = replace <EOL> return r <EOL> return _wrapped <EOL> return decorator <EOL> def csp ( ** kwargs ) : <EOL> config = dict ( <EOL> ( k . lower ( ) . replace ( '<STR_LIT:_>' , '<STR_LIT:->' ) , [ v ] if isinstance ( v , str ) else v ) <EOL> for k , v <EOL> in kwargs . items ( ) <EOL> ) <EOL> def decorator ( f ) : <EOL> @ wraps ( f ) <EOL> def _wrapped ( * a , ** kw ) : <EOL> r = f ( * a , ** kw ) <EOL> r . _csp_config = config <EOL> return r <EOL> return _wrapped <EOL> return decorator </s>
