#!/usr/bin/python -tt # # Copyright 2007, 2012 Toshio Kuratomi # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program. If not, see . '''Calculate how many packagers are Red Hat employees.''' import sys if __name__ == '__main__': userFilename = sys.argv[3] maintainerFilename = sys.argv[2] branchName = sys.argv[1] # Create a username => email mapping users = {} userFile = file(userFilename, 'r') for line in userFile: username, email, other = line.split(',', 2) users[username] = email userFile.close() # Read in information about maintainers of packages # Stats we've decided to gather. Explained below where they are printed totalRHPkgs = 0 totalNonRHPkgs = 0 solelyRHMaint = 0 solelyNonRHMaint = 0 mixedRHNonRHMaint = 0 solelyRHCommit = 0 solelyNonRHCommit = 0 mixedRHNonRHCommit = 0 totalOpenAcl = 0 totalOrphaned = 0 RHMaintainers = {} nonRHMaintainers = {} pkgFile = file(maintainerFilename, 'r') pkgs = {} for line in pkgFile: line = line.strip() if not line.endswith(branchName): continue # Parse the line into a data structure acl, maintainers, package = line.split(' | ') pkg = {} pkgs[package] = pkg if acl != 'avail': continue maintainers = maintainers.split(',') pkg['cvsextras'] = False pkg['provenpackager'] = False pkg['redhat'] = 0 pkg['nonredhat'] = 0 for person in maintainers: if person == '@cvsextras': pkg['cvsextras'] = True continue if person == '@provenpackager': pkg['provenpackager'] = True continue if users[person].endswith('@redhat.com'): RHMaintainers[person] = True pkg['redhat'] += 1 else: nonRHMaintainers[person] = True pkg['nonredhat'] += 1 # Add to category totals if pkg['redhat'] and pkg['nonredhat']: totalRHPkgs += 1 totalNonRHPkgs += 1 mixedRHNonRHMaint += 1 mixedRHNonRHCommit += 1 pass elif pkg['redhat']: totalRHPkgs += 1 solelyRHMaint += 1 if pkg['cvsextras'] or pkg['provenpackager']: mixedRHNonRHCommit += 1 else: solelyRHCommit += 1 pass elif pkg['nonredhat']: totalNonRHPkgs += 1 solelyNonRHMaint += 1 if pkg['cvsextras'] or pkg['provenpackager']: mixedRHNonRHCommit += 1 else: solelyNonRHCommit += 1 pass else: if pkg['cvsextras'] or pkg['provenpackager']: mixedRHNonRHCommit += 1 totalOrphaned += 1 if pkg['cvsextras'] or pkg['provenpackager']: totalOpenAcl += 1 pkgFile.close() # Summarise our findings print 'Total Packages:', len(pkgs.keys()) print 'Total RH Maintainers:', len(RHMaintainers.keys()) print 'Total NonRH Maintainers:', len(nonRHMaintainers.keys()) print print 'These stats are for people able to commit to the package.' print 'The first set disregards packages which are open for anyone to\ncommit:' print print 'Packages which have at least one Red Hat maintainer and packages\nwhich have at least one non-Red Hat maintainer:' print ' @redhat.com:', totalRHPkgs print ' !@redhat.com:', totalNonRHPkgs print print 'Packages which have solely Red Hat maintainers, solely non Red Hat\nmaintainers, and a mixture of both:' print ' solely @redhat.com:', solelyRHMaint print ' solely !@redhat.com:', solelyNonRHMaint print ' mixed redhat+!redhat:', mixedRHNonRHMaint print ' orphaned packages:', totalOrphaned print print 'This set factors in the possible effects of open acls (ie: anyone\nin cvsextras can commit:' print print 'Packages to which only Red Hat packagers can commit, only non Red Hat\npackagers can commit, or both:' print ' solely @redhat.com:', solelyRHCommit print ' solely !@redhat.com:', solelyNonRHCommit print ' mixed redhat+!redhat:', mixedRHNonRHCommit print 'Total Packages to which anyone can commit:', totalOpenAcl