Changeset 20 for launchpad_test.py

Show
Ignore:
Timestamp:
07/07/06 23:02:21 (3 years ago)
Author:
ploum
Message:

#22 : comments are not displayed in a bug

Yehaah ! Initial comments support. Not as easy as I thought

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • launchpad_test.py

    r18 r20  
    55import gtk.glade 
    66import urllib 
    7 from bug import bug 
     7from bug import * 
    88from BeautifulSoup import BeautifulSoup 
    99# You have to change this if you have another storage 
     
    1111 
    1212 
    13 zeurl="https://launchpad.net/products/malone/+bug/1" 
     13zeurl="https://launchpad.net/bugs/51835" 
    1414f= urllib.urlopen(zeurl) 
     15zebug = bug(42) 
    1516# ici on a le corps principal 
    1617# faudrait faire un extract pour soulager la mémoire 
     
    2122status = tbody[1].contents[0] 
    2223importance = tbody[2].contents[0] 
    23 assigned = tbody[3].a.contents[2] 
    24 #print title 
    25 #print product 
    26 #print status 
    27 #print importance 
     24#assigned = tbody[3].a.contents[2] 
     25print title 
     26print product 
     27print status 
     28print importance 
    2829#need to prettify assigned 
    2930#print assigned 
    30 content='' 
    31 p = soup.findAll('div', recursive=0)[1].div.findAll('p', recursive=0) 
    32 for i in p: 
    33         #print i.renderContents() 
    34         for j in i.contents: 
    35                 jj = j.string 
    36                 if jj != None and jj != "<br />" : 
    37                         print "#############################" 
    38                         newj = jj.strip().replace("&nbsp;"," ") 
    39                         print str(newj) 
    40                         content = "%s\n%s"%(content,newj) 
    41                         #print newj 
    42                 #print j.renderContents() 
    43                 #print "#####################" 
    44         content = "%s\n"%content 
    45 #print content 
     31array_com = soup.findAll('div', recursive=0)[1].findAll('div','boardComment') 
     32print array_com 
     33j = 0 
     34com_counter = 0 
     35for i in array_com : 
     36        details = i.contents[1].findAll('a') 
     37        title = details[0].strong.contents[0] 
     38        poster = details[1].contents[0] 
     39        body = i.contents[3].findAll('p') 
     40        com_counter += 1 
     41        content="" 
     42        for z in body : 
     43                phrase = z.contents[0].string 
     44                new_phrase = phrase.strip().replace("&nbsp;"," ") 
     45                content = "%s\n%s" %(content,new_phrase) 
     46        newcom = comment(com_counter,content,poster,title,"date not implemented") 
     47        zebug.addComment(newcom) 
     48        j += 1 
     49print zebug.comNbr() 
    4650 
    47 #p = soup.p 
    48 #content = p.contents[0] 
    49 #print p.name 
    50 #p = p.next 
    51 #print p 
    52 #p = p.nextSibling.nextSibling 
    53 #while p.name != 'form' : 
    54 #       print p.name 
    55 #       if p.name == 'p' : 
    56 #               content = content+'\n'+p.contents[0] 
    57 #       p = p.next 
    58 #print content 
    59  
    60