def select_autoescape(enabled_extensions=('html', 'htm', 'xml'), disabled_extensions=(), default_for_string=True, default=False):
 enabled_patterns = tuple((('.' + x.lstrip('.').lower()) for x in enabled_extensions))
 disabled_patterns = tuple((('.' + x.lstrip('.').lower()) for x in disabled_extensions))
 def autoescape(template_name):
  if (template_name is None):
   return default_for_string
  template_name = template_name.lower()
  if template_name.endswith(enabled_patterns):
   return True
  if template_name.endswith(disabled_patterns):
   return False
  return default
 return autoescape

def select_autoescape ( enabled_extensions = ( 'html' , 'htm' , 'xml' ) , disabled_extensions = ( ) , default_for_string = True , default = False ) : enabled_patterns = tuple ( ( ( '.' + x . lstrip ( '.' ) . lower ( ) ) for x in enabled_extensions ) ) disabled_patterns = tuple ( ( ( '.' + x . lstrip ( '.' ) . lower ( ) ) for x in disabled_extensions ) ) def autoescape ( template_name ) : if ( template_name is None ) : return default_for_string template_name = template_name . lower ( ) if template_name . endswith ( enabled_patterns ) : return True if template_name . endswith ( disabled_patterns ) : return False return default return autoescape
intelligently sets the initial value of autoescaping based on the filename of the template .