Last active
August 29, 2015 14:08
-
-
Save carlessanagustin/d402371856e6e02a4b21 to your computer and use it in GitHub Desktop.
(Python) Re-order dictionary for Buildbot CI Framework - Applied here: https://github.com/carlessanagustin/buildbot-bootstrap/blob/master/config/schedulers.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
build_names = [] | |
build_names.append(dict(name='build_id', branch='master', slaves=['bbslave'], | |
scheduler=['single', 'force', 'periodic', 'nightly'])) | |
build_names.append(dict(name='branch_id', branch='branch_id', slaves=['bbslave'], | |
scheduler=['single', 'periodic'])) | |
build_names.append(dict(name='branch_idm', branch='master', slaves=['bbslave'], | |
scheduler=['single', 'force','periodic'])) | |
print '' | |
print 'original: ', build_names | |
print '' | |
temp = [] | |
for build_name in build_names: | |
temp.extend(build_name['scheduler']) | |
sched_names = list(set(temp)) | |
branches = list(set([item['branch'] for item in build_names])) | |
scheduler_names = [] | |
for sched_name in sched_names: | |
for branch in branches: | |
build_names_branch = [item['name'] for item in build_names if (item['branch'] == branch) and (item['scheduler'].count(sched_name) == 1)] | |
if not len(build_names_branch) == 0: | |
scheduler_names.append(dict(scheduler=sched_name, name=build_names_branch, branch=branch)) | |
print 'result: ', scheduler_names | |
print '' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment