Changeset 17

Show
Ignore:
Timestamp:
07/06/06 11:59:18 (3 years ago)
Author:
ploum
Message:

#13 : launchpadweb searches incorrect results
#28 : results are not scrollable

Added BeautifulSoup? 3.0.3 from http://www.crummy.com/software/BeautifulSoup/
Thanks a lot to authors and contributors to BeautifulSoup?

Files:
2 added
2 modified

Legend:

Unmodified
Added
Removed
  • conseil.py

    r15 r17  
    1515        sys.exit(1) 
    1616 
    17 from protocol_dummy import protocol 
     17from protocol_launchpadweb import protocol 
    1818from bug import bug 
    1919 
     
    8080                # essai temporaire 
    8181                # normalement ici on lit le fichier de préférences 
    82                 listing.insert_before(None, ["UNCONFIRMED", 2, "blablabla"]) 
    83                 listing.insert_before(None, ["Evo's bugs", 3, "evolution bugs"]) 
     82                listing.insert_before(None, ["3 results", 2, "nautilus evolution crash"]) 
     83                listing.insert_before(None, ["many results", 2, "microsoft has majority"]) 
     84                listing.insert_before(None, ["Evo's bugs", 3, "evolution refresh folder"]) 
    8485                listing.insert_before(None, ["Bug #42", 1, "42"]) 
    8586                renderer = gtk.CellRendererText() 
     
    184185                tree.set_rules_hint(1) 
    185186                tree.set_model(store) 
    186                 self.insertTab(tree,title) 
     187                tab = gtk.ScrolledWindow() 
     188                tab.show() 
     189                tab.add(tree) 
     190                self.insertTab(tab,title) 
    187191                 
    188192 
     
    222226                        page = self.bugs_tabs.page_num(data) 
    223227                        self.bugs_tabs.remove_page(page) 
    224  
    225228                tab = widget 
    226229                #this is ugly ! I don't want to use glade for this 
  • protocol_launchpadweb.py

    r12 r17  
    55import urllib 
    66from bug import bug 
     7from BeautifulSoup import BeautifulSoup 
    78# You have to change this if you have another storage 
    89from auth_dummy import user 
     
    2324        def Name(self): 
    2425                return "launchpadweb" 
     26 
     27        # send the name of the bts this protocol will talk too. 
     28        # this is intended for future multi-protocol support 
     29        # and will enable bookmarks sharing between differents protocols 
     30        # that speaks to the same bts 
     31        def bts(self): 
     32                return "launchpad" 
    2533 
    2634################BUG RETRIEVING IN THE BTS ################################# 
     
    8088         
    8189        # content is an array of bug numbers 
    82         def __populateResult(self, results, content): 
    83                 #boucle pour n'afficher que 10 bugs (c'est une démo) 
    84                 j = 0 
    85                 for i in content : 
    86                         #besoin de prog défensive ici FIXME 
    87                         nbr=int(i) 
    88                         print "processing bug %s" %j 
    89                         bug = self.retrieveBug(nbr) 
    90                         results.insert_before(None, [nbr, bug.getPackage(), bug.getTitle(), bug.getImportance(), bug.getStatus()]) 
    91                         j += 1 
    92                         if j > 10 : break 
     90        def __populateResult(self, results, content, typeofsearch, arg_package): 
     91                table = content.body.findAll('tbody')[1].findAll('tr') 
     92                for tr in table : 
     93                        row = tr.findAll('td') 
     94                        nbr = int(row[1].contents[0]) 
     95                        title = row[2].a.contents[0] 
     96                        if typeofsearch == 2 : 
     97                                package = row[3].contents[0] 
     98                                importance = row[4].contents[0] 
     99                                status = row[5].contents[0] 
     100                        elif typeofsearch == 3 : 
     101                                package = arg_package 
     102                                importance = row[3].contents[0] 
     103                                status = row[4].contents[0] 
     104                        else : 
     105                                package = '' 
     106                                importance = '' 
     107                                status = '' 
     108                        results.insert_before(None, [nbr, package, title, importance, status ]) 
    93109                return results 
     110 
    94111 
    95112        # genericSearch on a given string search_str. 
     
    101118                #inserting dummies bugs 
    102119                plus = search_str.replace(" ","+") 
    103                 zeurl="https://launchpad.net/distros/ubuntu/+bugs-text?field.searchtext=%s" %plus 
     120                zeurl="https://launchpad.net/distros/ubuntu/+bugs?field.searchtext=%s" %plus 
    104121                f= urllib.urlopen(zeurl) 
    105                 content=f.readlines() 
    106                 return self.__populateResult(results, content) 
     122                content=BeautifulSoup(f) 
     123                return self.__populateResult(results, content, 2, None) 
    107124         
    108125                 
     
    121138                if search_str != None : 
    122139                        plus = search_str.replace(" ","+") 
    123                         zeurl="https://launchpad.net/distros/ubuntu/+source/%s/+bugs-text?field.searchtext=%s" %(package,plus) 
     140                        zeurl="https://launchpad.net/distros/ubuntu/+source/%s/+bugs?field.searchtext=%s" %(package,plus) 
    124141                else : 
    125                         zeurl="https://launchpad.net/distros/ubuntu/+source/%s/+bugs-text" %package 
     142                        zeurl="https://launchpad.net/distros/ubuntu/+source/%s/+bugs" %package 
    126143                f= urllib.urlopen(zeurl) 
    127                 content=f.readlines() 
    128                 return self.__populateResult(results, content) 
     144                content=BeautifulSoup(f) 
     145                return self.__populateResult(results, content, 3, package) 
    129146                 
    130147                #%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%