def patch_cache_control(response, **kwargs):
 def dictitem(s):
  t = s.split('=', 1)
  if (len(t) > 1):
   return (t[0].lower(), t[1])
  else:
   return (t[0].lower(), True)
 def dictvalue(t):
  if (t[1] is True):
   return t[0]
  else:
   return ((t[0] + '=') + smart_str(t[1]))
 if response.has_header('Cache-Control'):
  cc = cc_delim_re.split(response['Cache-Control'])
  cc = dict([dictitem(el) for el in cc])
 else:
  cc = {}
 if (('max-age' in cc) and ('max_age' in kwargs)):
  kwargs['max_age'] = min(cc['max-age'], kwargs['max_age'])
 for (k, v) in kwargs.items():
  cc[k.replace('_', '-')] = v
 cc = ', '.join([dictvalue(el) for el in cc.items()])
 response['Cache-Control'] = cc

def patch_cache_control ( response , ** kwargs ) : def dictitem ( s ) : t = s . split ( '=' , 1 ) if ( len ( t ) > 1 ) : return ( t [ 0 ] . lower ( ) , t [ 1 ] ) else : return ( t [ 0 ] . lower ( ) , True ) def dictvalue ( t ) : if ( t [ 1 ] is True ) : return t [ 0 ] else : return ( ( t [ 0 ] + '=' ) + smart_str ( t [ 1 ] ) ) if response . has_header ( 'Cache-Control' ) : cc = cc_delim_re . split ( response [ 'Cache-Control' ] ) cc = dict ( [ dictitem ( el ) for el in cc ] ) else : cc = { } if ( ( 'max-age' in cc ) and ( 'max_age' in kwargs ) ) : kwargs [ 'max_age' ] = min ( cc [ 'max-age' ] , kwargs [ 'max_age' ] ) for ( k , v ) in kwargs . items ( ) : cc [ k . replace ( '_' , '-' ) ] = v cc = ', ' . join ( [ dictvalue ( el ) for el in cc . items ( ) ] ) response [ 'Cache-Control' ] = cc
this function patches the cache-control header by adding all keyword arguments to it .