@@ -0,0 +1,1561 @@
+import sys, os, urllib, StringIO, traceback, cgi, binascii, getopt%0Aimport store, config%0A%0Atry:%0A    config = config.Config(sys.argv%5B1%5D, 'webui')%0Aexcept IndexError:%0A    print %22Usage: find_dups.py config.ini%22%0A    raise SystemExit%0A%0Astore = store.Store(config)%0Astore.open()%0A%0Adef owner_email(p):%0A    result = set()%0A    for r,u in store.get_package_roles(p):%0A        if r == 'Owner':%0A            result.add(store.get_user(u)%5B'email'%5D)%0A    return result%0A%0Adef mail_dup(email, package1, package2):%0A    email = %22martin@v.loewis.de%22%0A    f = os.popen(%22/usr/lib/sendmail %22+email, %22w%22)%0A    f.write(%22To: %25s%5Cn%22 %25 email)%0A    f.write(%22From: martin@v.loewis.de%5Cn%22)%0A    f.write(%22Subject: Please cleanup PyPI package names%5Cn%5Cn%22)%0A    f.write(%22Dear Package Owner,%5Cn%22)%0A    f.write(%22You have currently registered the following to packages,%5Cn%22)%0A    f.write(%22which differ only in case:%5Cn%5Cn%25s%5Cn%25s%5Cn%5Cn%22 %25 (package1, package2))%0A    f.write(%22As a recent policy change, we are now rejecting this kind of%5Cn%22)%0A    f.write(%22setup. Please remove one of packages.%5Cn%5Cn%22)%0A    f.write(%22If you need assistance, please let me know.%5Cn%5Cn%22)%0A    f.write(%22Kind regards,%5CnMartin v. Loewis%5Cn%22)%0A    f.close()%0A%0Alower = %7B%7D%0Afor name,version in store.get_packages():%0A    lname = name.lower()%0A    if lname in lower:%0A        owner1 = owner_email(name)%0A        owner2 = owner_email(lower%5Blname%5D)%0A        owners = owner1.intersection(owner2)%0A        if owners:%0A            mail_dup(owners.pop(),name,lower%5Blname%5D)%0A        else:%0A            print %22Distinct dup%22, name, lower%5Blname%5D, owner1, owner2%0A    lower%5Blname%5D = name%0A

Add script to email users of name-conflicting packages.