def html_quote(v, encoding=None):
 encoding = (encoding or default_encoding)
 if (v is None):
  return ''
 elif isinstance(v, six.binary_type):
  return cgi.escape(v, 1)
 elif isinstance(v, six.text_type):
  if six.PY3:
   return cgi.escape(v, 1)
  else:
   return cgi.escape(v.encode(encoding), 1)
 elif six.PY3:
  return cgi.escape(six.text_type(v), 1)
 else:
  return cgi.escape(six.text_type(v).encode(encoding), 1)

def html_quote ( v , encoding = None ) : encoding = ( encoding or default_encoding ) if ( v is None ) : return '' elif isinstance ( v , six . binary_type ) : return cgi . escape ( v , 1 ) elif isinstance ( v , six . text_type ) : if six . PY3 : return cgi . escape ( v , 1 ) else : return cgi . escape ( v . encode ( encoding ) , 1 ) elif six . PY3 : return cgi . escape ( six . text_type ( v ) , 1 ) else : return cgi . escape ( six . text_type ( v ) . encode ( encoding ) , 1 )
escape html characters .