當前位置: 首頁>>代碼示例>>Python>>正文


Python IBox.td方法代碼示例

本文整理匯總了Python中buildbot.status.web.base.IBox.td方法的典型用法代碼示例。如果您正苦於以下問題:Python IBox.td方法的具體用法?Python IBox.td怎麽用?Python IBox.td使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在buildbot.status.web.base.IBox的用法示例。


在下文中一共展示了IBox.td方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: phase1

# 需要導入模塊: from buildbot.status.web.base import IBox [as 別名]
# 或者: from buildbot.status.web.base.IBox import td [as 別名]
 def phase1(self, request, sourceNames, timestamps, eventGrid,
            sourceEvents):
     # phase1 rendering: table, but boxes do not overlap
     data = ""
     if not timestamps:
         return data
     lastDate = None
     for r in range(0, len(timestamps)):
         chunkstrip = eventGrid[r]
         # chunkstrip is a horizontal strip of event blocks. Each block
         # is a vertical list of events, all for the same source.
         assert(len(chunkstrip) == len(sourceNames))
         maxRows = reduce(lambda x,y: max(x,y),
                          map(lambda x: len(x), chunkstrip))
         for i in range(maxRows):
             data += " <tr>\n";
             if i == 0:
                 stuff = []
                 # add the date at the beginning, and each time it changes
                 today = time.strftime("<b>%d %b %Y</b>",
                                       time.localtime(timestamps[r]))
                 todayday = time.strftime("<b>%a</b>",
                                          time.localtime(timestamps[r]))
                 if today != lastDate:
                     stuff.append(todayday)
                     stuff.append(today)
                     lastDate = today
                 stuff.append(
                     time.strftime("%H:%M:%S",
                                   time.localtime(timestamps[r])))
                 data += td(stuff, valign="bottom", align="center",
                            rowspan=maxRows, class_="Time")
             for c in range(0, len(chunkstrip)):
                 block = chunkstrip[c]
                 assert(block != None) # should be [] instead
                 # bottom-justify
                 offset = maxRows - len(block)
                 if i < offset:
                     data += td("")
                 else:
                     e = block[i-offset]
                     box = IBox(e).getBox(request)
                     box.parms["show_idle"] = 1
                     data += box.td(valign="top", align="center")
             data += " </tr>\n"
     
     return data
開發者ID:aloisiojr,項目名稱:buildbot,代碼行數:49,代碼來源:waterfall.py

示例2: phase2

# 需要導入模塊: from buildbot.status.web.base import IBox [as 別名]
# 或者: from buildbot.status.web.base.IBox import td [as 別名]

#.........這裏部分代碼省略.........
                                          time.localtime(timestamps[r]))
                    if today != lastDate:
                        stuff.append(todayday)
                        stuff.append(today)
                        lastDate = today
                    stuff.append(
                        time.strftime("%H:%M:%S",
                                      time.localtime(timestamps[r])))
                    grid[0].append(Box(text=stuff, class_="Time",
                                       valign="bottom", align="center"))

            # at this point the timestamp column has been populated with
            # maxRows boxes, most None but the last one has the time string
            for c in range(0, len(chunkstrip)):
                block = chunkstrip[c]
                assert(block != None) # should be [] instead
                for i in range(maxRows - len(block)):
                    # fill top of chunk with blank space
                    grid[c+1].append(None)
                for i in range(len(block)):
                    # so the events are bottom-justified
                    b = IBox(block[i]).getBox(request)
                    b.parms['valign'] = "top"
                    b.parms['align'] = "center"
                    grid[c+1].append(b)
            # now all the other columns have maxRows new boxes too
        # populate the last row, if empty
        gridlen = len(grid[0])
        for i in range(len(grid)):
            strip = grid[i]
            assert(len(strip) == gridlen)
            if strip[-1] == None:
                if sourceEvents[i-1]:
                    filler = IBox(sourceEvents[i-1]).getBox(request)
                else:
                    # this can happen if you delete part of the build history
                    filler = Box(text=["?"], align="center")
                strip[-1] = filler
            strip[-1].parms['rowspan'] = 1
        # second pass: bubble the events upwards to un-occupied locations
        # Every square of the grid that has a None in it needs to have
        # something else take its place.
        noBubble = request.args.get("nobubble",['0'])
        noBubble = int(noBubble[0])
        if not noBubble:
            for col in range(len(grid)):
                strip = grid[col]
                if col == 1: # changes are handled differently
                    for i in range(2, len(strip)+1):
                        # only merge empty boxes. Don't bubble commit boxes.
                        if strip[-i] == None:
                            next = strip[-i+1]
                            assert(next)
                            if next:
                                #if not next.event:
                                if next.spacer:
                                    # bubble the empty box up
                                    strip[-i] = next
                                    strip[-i].parms['rowspan'] += 1
                                    strip[-i+1] = None
                                else:
                                    # we are above a commit box. Leave it
                                    # be, and turn the current box into an
                                    # empty one
                                    strip[-i] = Box([], rowspan=1,
                                                    comment="commit bubble")
                                    strip[-i].spacer = True
                            else:
                                # we are above another empty box, which
                                # somehow wasn't already converted.
                                # Shouldn't happen
                                pass
                else:
                    for i in range(2, len(strip)+1):
                        # strip[-i] will go from next-to-last back to first
                        if strip[-i] == None:
                            # bubble previous item up
                            assert(strip[-i+1] != None)
                            strip[-i] = strip[-i+1]
                            strip[-i].parms['rowspan'] += 1
                            strip[-i+1] = None
                        else:
                            strip[-i].parms['rowspan'] = 1
        # third pass: render the HTML table
        for i in range(gridlen):
            data += " <tr>\n";
            for strip in grid:
                b = strip[i]
                if b:
                    # convert data to a unicode string, whacking any non-ASCII characters it might contain
                    s = b.td()
                    if isinstance(s, unicode):
                        s = s.encode("utf-8", "replace")
                    data += s
                else:
                    if noBubble:
                        data += td([])
                # Nones are left empty, rowspan should make it all fit
            data += " </tr>\n"
        return data
開發者ID:aloisiojr,項目名稱:buildbot,代碼行數:104,代碼來源:waterfall.py


注:本文中的buildbot.status.web.base.IBox.td方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。