Source

python-stdlib / modstats.py

Full commit
#---
#
# Get statistics for modules from standard Python library
#
#---
"""
  [ ] open patches per module
    [x] get list of all open issues with patches
    [ ] get patch files for each issue
    [ ] extract paths from each patch
    [ ] detect modules for the issue using paths
    [ ] print list of modules and issues

"""

# -- 1. Get list of all open issues with patches --
#
# Using http://roundup.sourceforge.net/docs/xmlrpc.html
# 
# [ ] patch keyword filtering may not be reliable
#   [ ] get list of all issues with attachments
#   [ ] filter patches
#

try:
  import xmlrpclib
except ImportError:  # Python 3
  import xmlrpc.client as xmlrpclib

bpo = xmlrpclib.ServerProxy('http://bugs.python.org', allow_none=True)

open_status = [bpo.lookup('status', x) for x in bpo.list('status')
               if x != 'closed']
patch_keyword = bpo.lookup('keyword', 'patch')

open_issues = bpo.filter('issue', None, {'status':open_status, 'keywords':patch_keyword})
#print(open_issues)
print('Opened issues with patch keyword: %s' % len(open_issues))


# -- 2. read patch files for each issue and get paths per issue

files_attached = 0
files_patches = []

for issue in open_issues:
  print(issue)
  for filename in bpo.display('issue'+issue, 'files')['files']:
    print("  " + filename)
    files_attached += 1