[users at bb.net] Sort tags in natural order

Ryan Schmidt buildbot at ryandesign.com
Sat Aug 6 16:11:27 UTC 2016


On Aug 5, 2016, at 8:57 AM, Ryan Schmidt wrote:
> 
> With buildbot 0.8.12, I notice that when a list of tags is printed, either at the top of the waterfall, or the top of the console page, or when used to group the builders on the console page, the tags are sorted in alphabetical order. I would like them sorted in natural order instead (i.e. "10.9" comes before "10.10").
> 
> 
> To fix console.py, I changed this line:
> 
>        tags = sorted(builderList.keys())
> 
> With this line:
> 
>        tags = util.naturalSort(builderList.keys())

Here is the patch we're using to fix the sort order on the console page:

https://trac.macports.org/browser/trunk/dports/devel/buildbot/files/patch-buildbot-status-web-console.py.diff


Here is another patch to fix the sort order of builders on the grid and transposed grid pages:

https://trac.macports.org/browser/trunk/dports/devel/buildbot/files/patch-buildbot-status-web-grid.py.diff


> In waterfall.py, in this block:
> 
>        # get alphabetically sorted list of all tags
>        tags = set()
>        builderNames = status.getBuilderNames()
>        for builderName in builderNames:
>            builder = status.getBuilder(builderName)
>            tags.update(builder.getTags() or [])
>        tags = sorted(tags)
>        ctx['tags'] = tags
> 
> I tried replacing this line:
> 
>        tags = sorted(tags)
> 
> With this line:
> 
>        tags = util.naturalSort(tags)
> 
> And I got this error:
> 
> exceptions.TypeError: 'set' object has no attribute '__getitem__'
> 
> I guess this is because in the waterfall, tags is a set not a list, but I do not know Python so I don't know how best to fix it.

Looks like it's easy to convert a set to a list, and that sorted() is already doing so. Here's the patch for the waterfall page:

https://trac.macports.org/browser/trunk/dports/devel/buildbot/files/patch-buildbot-status-web-waterfall.py.diff





More information about the users mailing list