def xml_format(a):
 if isinstance(a, basestring):
  return ('"%s"' % encode_entities(a))
 if isinstance(a, bool):
  return ('"%s"' % ('no', 'yes')[int(a)])
 if isinstance(a, (int, long)):
  return ('"%s"' % a)
 if isinstance(a, float):
  return ('"%s"' % round(a, 5))
 if isinstance(a, type(None)):
  return '""'
 if isinstance(a, Date):
  return ('"%s"' % str(a))
 if isinstance(a, datetime.datetime):
  return ('"%s"' % str(date(mktime(a.timetuple()))))

def xml_format ( a ) : if isinstance ( a , basestring ) : return ( '"%s"' % encode_entities ( a ) ) if isinstance ( a , bool ) : return ( '"%s"' % ( 'no' , 'yes' ) [ int ( a ) ] ) if isinstance ( a , ( int , long ) ) : return ( '"%s"' % a ) if isinstance ( a , float ) : return ( '"%s"' % round ( a , 5 ) ) if isinstance ( a , type ( None ) ) : return '""' if isinstance ( a , Date ) : return ( '"%s"' % str ( a ) ) if isinstance ( a , datetime . datetime ) : return ( '"%s"' % str ( date ( mktime ( a . timetuple ( ) ) ) ) )
returns the given attribute as a quoted unicode string .