Changeset 17
- Timestamp:
- 07/06/06 11:59:18 (3 years ago)
- Files:
-
- 2 added
- 2 modified
-
BeautifulSoup.py (added)
-
conseil.py (modified) (4 diffs)
-
launchpad_test.py (added)
-
protocol_launchpadweb.py (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
conseil.py
r15 r17 15 15 sys.exit(1) 16 16 17 from protocol_ dummyimport protocol17 from protocol_launchpadweb import protocol 18 18 from bug import bug 19 19 … … 80 80 # essai temporaire 81 81 # 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"]) 84 85 listing.insert_before(None, ["Bug #42", 1, "42"]) 85 86 renderer = gtk.CellRendererText() … … 184 185 tree.set_rules_hint(1) 185 186 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) 187 191 188 192 … … 222 226 page = self.bugs_tabs.page_num(data) 223 227 self.bugs_tabs.remove_page(page) 224 225 228 tab = widget 226 229 #this is ugly ! I don't want to use glade for this -
protocol_launchpadweb.py
r12 r17 5 5 import urllib 6 6 from bug import bug 7 from BeautifulSoup import BeautifulSoup 7 8 # You have to change this if you have another storage 8 9 from auth_dummy import user … … 23 24 def Name(self): 24 25 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" 25 33 26 34 ################BUG RETRIEVING IN THE BTS ################################# … … 80 88 81 89 # 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 ]) 93 109 return results 110 94 111 95 112 # genericSearch on a given string search_str. … … 101 118 #inserting dummies bugs 102 119 plus = search_str.replace(" ","+") 103 zeurl="https://launchpad.net/distros/ubuntu/+bugs -text?field.searchtext=%s" %plus120 zeurl="https://launchpad.net/distros/ubuntu/+bugs?field.searchtext=%s" %plus 104 121 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) 107 124 108 125 … … 121 138 if search_str != None : 122 139 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) 124 141 else : 125 zeurl="https://launchpad.net/distros/ubuntu/+source/%s/+bugs -text" %package142 zeurl="https://launchpad.net/distros/ubuntu/+source/%s/+bugs" %package 126 143 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) 129 146 130 147 #%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
