当前位置: 首页>>代码示例>>Python>>正文


Python base.IBox类代码示例

本文整理汇总了Python中buildbot.status.web.base.IBox的典型用法代码示例。如果您正苦于以下问题:Python IBox类的具体用法?Python IBox怎么用?Python IBox使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了IBox类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: phase1

 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,代码行数:47,代码来源:waterfall.py

示例2: GenBox

 def GenBox(item):
   """Generates a box for one build step."""
   # Fix the url root.
   box_text = IBox(item).getBox(request).td(align='center').replace(
                  'href="builders/',
                  'href="' + waterfall_url + 'builders/')
   # Convert CSS classes to inline style.
   match = re.search(r"class=\"([^\"]*)\"", box_text)
   if match:
     css_class_text = match.group(1)
     css_classes = css_class_text.split()
     not_found = [c for c in css_classes if c not in styles]
     css_classes = [c for c in css_classes if c in styles]
     if len(not_found):
       log.msg('CSS classes couldn\'t be converted in inline style in '
               'email: %s' % str(not_found))
     inline_styles = ' '.join([styles[c] for c in css_classes])
     box_text = box_text.replace('class="%s"' % css_class_text,
                                 'style="%s"' % inline_styles)
   else:
     log.msg('Couldn\'t find the class attribute')
   return '<tr>%s</tr>\n' % box_text
开发者ID:leiferikb,项目名称:bitpop,代码行数:22,代码来源:build_utils.py

示例3: phase2

    def phase2(self, request, sourceNames, timestamps, eventGrid,
               sourceEvents):
        data = ""
        if not timestamps:
            return data
        # first pass: figure out the height of the chunks, populate grid
        grid = []
        for i in range(1+len(sourceNames)):
            grid.append([])
        # grid is a list of columns, one for the timestamps, and one per
        # event source. Each column is exactly the same height. Each element
        # of the list is a single <td> box.
        lastDate = time.strftime("<b>%d %b %Y</b>",
                                 time.localtime(util.now()))
        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):
                if i != maxRows-1:
                    grid[0].append(None)
                else:
                    # timestamp goes at the bottom of the chunk
                    stuff = []
                    # add the date at the beginning (if it is not the same as
                    # today's date), and each time it changes
                    todayday = time.strftime("<b>%a</b>",
                                             time.localtime(timestamps[r]))
                    today = time.strftime("<b>%d %b %Y</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])))
                    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:
#.........这里部分代码省略.........
开发者ID:aloisiojr,项目名称:buildbot,代码行数:101,代码来源:waterfall.py


注:本文中的buildbot.status.web.base.IBox类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。