예제 #1
0
 def list(self):
     bugrss = geturl(self.list_url())
     bugdom = xml.dom.minidom.parseString(bugrss)
     bugall = bugdom.getElementsByTagName('entry')
     bugs = []
     if bugall:
         for entry in bugall:
             try:
                 bugid = entry.getElementsByTagName('id')[0].firstChild.nodeValue.split(':')[2]
                 bugs.append(bugid)
             except:
                 pass
     return bugs
예제 #2
0
 def comments(self, bugId):
     assert bugId.isdigit(), "bug id has to be a number"
     bugrss = geturl(self.comments_url(bugId))
     bugdom = xml.dom.minidom.parseString(bugrss)
     bugall = bugdom.getElementsByTagName('item')
     comments = []
     if bugall:
         for item in bugall:
             title = item.getElementsByTagName('title')[0].firstChild.nodeValue
             if 'comment added' in title:
                 try:
                     author = item.getElementsByTagName('dc:creator')[0].firstChild.nodeValue
                 except IndexError:
                     author = 'anonymous'
                 comment = item.getElementsByTagName('description')[0].firstChild.nodeValue
                 comment = striphtml(comment.replace('\n', ' ')).strip()
                 while '  ' in comment:
                     comment = comment.replace('  ', ' ')
                 comments.append('%s: %s' % (author, comment))
     return comments    
예제 #3
0
 def show(self, bugId):
     assert bugId.isdigit(), "bug id has to be a number"
     bugxml = geturl(self.show_url_xml(bugId))
     bugdom = xml.dom.minidom.parseString(bugxml)
     try:
         bugset = bugdom.getElementsByTagName('bug')[0]
     except:
         raise BugTrackerNotFound('could not find bug tag')
     bugget = {'creation_ts': 'created', 'product': 'product', 'component': 'component',
         'version': 'version', 'bug_status': 'status', 'resolution': 'resolution',
         'priority': 'priority', 'bug_severity': 'severity', 'reporter': 'reporter',
         'short_desc': 'description', 'assigned_to': 'assigned to'}
     data = {}
     for tag in list(bugget.keys()):
         try:
             value = bugset.getElementsByTagName(tag)[0].firstChild.nodeValue
             data[bugget[tag]] = value
         except:
             pass
     return data
예제 #4
0
파일: wikipedia.py 프로젝트: buzzworkers/tl
def getwikidata(url):
    """ fetch wiki data """
    try:
        result = geturl(url)
    except IOError as ex: logging.error("error fetching %s: %s" % (url, str(ex))) ; return 
    if not result: return
    res = rsslist(result)
    txt = ""
    for i in res:
        try:
            logging.debug(str(i))
            txt = i['text']
            break
        except: pass
    txt = re.sub('\[\[(.*?)\]\]', '<b>\g<1></b>', txt)
    txt = re.sub('{{(.*?)}}', '<i>\g<1></i>', txt)
    txt = re.sub('==(.*?)==', '<h3>\g<1></h3>', txt)
    txt = re.sub('=(.*?)=', '<h2>\g<1></h2>', txt)
    txt = re.sub('\*(.*?)\n', '<li>\g<1></li>', txt)
    txt = re.sub('\n\n', '<br><br>', txt)
    txt = re.sub('\s+', ' ', txt)
    txt = txt.replace('|', ' - ')
    return txt