def websafe(val):
 if (val is None):
  return u''
 if PY2:
  if isinstance(val, str):
   val = val.decode('utf-8')
  elif (not isinstance(val, unicode)):
   val = unicode(val)
 elif isinstance(val, bytes):
  val = val.decode('utf-8')
 elif (not isinstance(val, str)):
  val = str(val)
 return htmlquote(val)

def websafe ( val ) : if ( val is None ) : return u'' if PY2 : if isinstance ( val , str ) : val = val . decode ( 'utf-8' ) elif ( not isinstance ( val , unicode ) ) : val = unicode ( val ) elif isinstance ( val , bytes ) : val = val . decode ( 'utf-8' ) elif ( not isinstance ( val , str ) ) : val = str ( val ) return htmlquote ( val )
converts val so that it is safe for use in unicode html .