def _quotify(mystr):
 quote = '"'
 l = len(mystr)
 for i in range(l):
  if ((mystr[i] == '\\') and ((i + 1) < l) and (mystr[(i + 1)] == "'")):
   quote = "'"
   break
  elif ((mystr[i] == '\\') and ((i + 1) < l) and (mystr[(i + 1)] == '"')):
   quote = '"'
   break
  elif (mystr[i] == "'"):
   quote = '"'
   break
  elif (mystr[i] == '"'):
   quote = "'"
   break
 return ((quote + mystr) + quote)

def _quotify ( mystr ) : quote = '"' l = len ( mystr ) for i in range ( l ) : if ( ( mystr [ i ] == '\\' ) and ( ( i + 1 ) < l ) and ( mystr [ ( i + 1 ) ] == "'" ) ) : quote = "'" break elif ( ( mystr [ i ] == '\\' ) and ( ( i + 1 ) < l ) and ( mystr [ ( i + 1 ) ] == '"' ) ) : quote = '"' break elif ( mystr [ i ] == "'" ) : quote = '"' break elif ( mystr [ i ] == '"' ) : quote = "'" break return ( ( quote + mystr ) + quote )
quotifies an html tag attribute value .