Changeset 20 for bugglade_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
  • bugglade_test.py

    r18 r20  
    55import gtk.glade 
    66import urllib 
    7 from bug import bug 
     7from bug import * 
     8from protocol_launchpadweb import protocol 
    89from BeautifulSoup import BeautifulSoup 
    910# You have to change this if you have another storage 
     
    1112 
    1213 
    13 bugnbr="42" 
    14 nbr=int(bugnbr) 
    15  
    16 zebug = bug(nbr) 
    17  
    18 zeurl="https://launchpad.net/products/malone/+bug/1" 
    19 f= urllib.urlopen(zeurl) 
    20 # ici on a le corps principal 
    21 # faudrait faire un extract pour soulager la mémoire 
    22 soup = BeautifulSoup(f).body.contents[5].div.div 
    23 title = soup.h1.contents[0] 
    24 tbody = soup.findAll('tbody')[0].findAll('td') 
    25 product = tbody[0].a.contents[0] 
    26 status = tbody[1].contents[0] 
    27 importance = tbody[2].contents[0] 
    28 assigned = tbody[3].a.contents[2] 
    29 zebug.setTitle(title) 
    30 zebug.setPackage(product) 
    31 zebug.setStatus(status) 
    32 zebug.setImportance(importance) 
    33 zebug.setAssignee(assigned) 
    34 #need to prettify assigned 
    35 content='' 
    36 p = soup.findAll('div', recursive=0)[1].div.findAll('p', recursive=0) 
    37 for i in p: 
    38         for j in i.contents: 
    39                 content = "%s\n%s"%(content,j) 
    40 zebug.setDescription(content) 
     14bts = protocol() 
     15zebug = bts.retrieveBug(42) 
     16bugnbr = str(zebug.getNbr()) 
    4117 
    4218 
     
    4622bugwidget.signal_autoconnect(dic) 
    4723 
     24widget_comments_nbr = bugwidget.get_widget("comments_nbr") 
     25com_text = "%d comment(s) : "%zebug.comNbr() 
     26widget_comments_nbr.set_text(com_text) 
     27widget_comments = bugwidget.get_widget("com_frame") 
    4828widget_nbr = bugwidget.get_widget("number")  
    4929widget_nbr.set_text(bugnbr) 
     
    6141widget_package.set_text(zebug.getPackage()) 
    6242 
     43#inserting comments 
     44hbox = gtk.VBox(spacing=2) 
     45hbox.show() 
     46for i in zebug.getAllComments(): 
     47        comwidget = gtk.glade.XML("comment.glade") 
     48        comwidget.get_widget("poster").set_text(i.getAuthor()) 
     49        comwidget.get_widget("title").set_text(i.getTitle()) 
     50        comwidget.get_widget("date").set_text(i.getDate()) 
     51        comwidget.get_widget("comment_body").set_text(i.getContent()) 
     52        hbox.add(comwidget.get_widget("comment")) 
     53 
     54 
     55to_remove = bugwidget.get_widget("dummy_label") 
     56widget_comments.remove(to_remove) 
     57widget_comments.add(hbox) 
     58 
    6359#We take the vbox to insert it 
    6460main_widget = bugwidget.get_widget("bug_main")