def dlcs_parse_xml(data, split_tags=False):
 if (DEBUG > 3):
  print >>sys.stderr, 'dlcs_parse_xml: parsing from ', data
 if (not hasattr(data, 'read')):
  data = StringIO(data)
 doc = parse_xml(data)
 root = doc.getroot()
 fmt = root.tag
 if (fmt in ('tags', 'posts', 'dates', 'bundles')):
  elist = [el.attrib for el in doc.findall(fmt[:(-1)])]
  data = {fmt: elist}
  data.update(root.attrib)
  return data
 elif (fmt == 'result'):
  if root.attrib.has_key('code'):
   msg = root.attrib['code']
  else:
   msg = root.text
  v = (msg in DLCS_OK_MESSAGES)
  return {fmt: (v, msg)}
 elif (fmt == 'update'):
  return {fmt: {'time': time.strptime(root.attrib['time'], ISO_8601_DATETIME)}}
 else:
  raise PyDeliciousException, ("Unknown XML document format '%s'" % fmt)

def dlcs_parse_xml ( data , split_tags = False ) : if ( DEBUG > 3 ) : print >> sys . stderr , 'dlcs_parse_xml: parsing from ' , data if ( not hasattr ( data , 'read' ) ) : data = StringIO ( data ) doc = parse_xml ( data ) root = doc . getroot ( ) fmt = root . tag if ( fmt in ( 'tags' , 'posts' , 'dates' , 'bundles' ) ) : elist = [ el . attrib for el in doc . findall ( fmt [ : ( - 1 ) ] ) ] data = { fmt : elist } data . update ( root . attrib ) return data elif ( fmt == 'result' ) : if root . attrib . has_key ( 'code' ) : msg = root . attrib [ 'code' ] else : msg = root . text v = ( msg in DLCS_OK_MESSAGES ) return { fmt : ( v , msg ) } elif ( fmt == 'update' ) : return { fmt : { 'time' : time . strptime ( root . attrib [ 'time' ] , ISO_8601_DATETIME ) } } else : raise PyDeliciousException , ( "Unknown XML document format '%s'" % fmt )
parse any del .