"pypi-scrape-crawl": set(), } accepted_modes = { "pypi-scrape-crawl": ["pypi-scrape-crawl", "pypi-scrape", "pypi-explicit"], "pypi-scrape": ["pypi-scrape", "pypi-explicit"], "pypi-explicit": ["pypi-explicit"], } store.open() for desired_mode, names in data.iteritems(): if desired_mode == "pypi-scrape-crawl": continue # We don't need to do any processing for pypi-scrape-crawl for name in names: packages = store.find_package(name) if not packages: continue # This doesn't exist assert safe_name(name).lower() == safe_name(packages[0]).lower() name = packages[0] current_mode = store.get_package_hosting_mode(name) if current_mode not in accepted_modes[desired_mode]: store.set_package_hosting_mode(name, desired_mode) processed[desired_mode].add(name) store.commit() with open("migrated.pkl", "wb") as pkl: pickle.dump(processed, pkl)
print("Rename packages where the only invalid name is a space") for name in junk_names: if name.strip() != name: continue if valid_name.search(name.replace(" ", "-")) is not None: new_name = re.sub("\s+", "-", name) renamed.append((name, new_name)) store.rename_package(name, new_name) else: new_name = re.sub("[^A-Za-z0-9.]+", "-", name).strip("_-.") if valid_name.search(new_name) is None: continue num = 2 onew_name = new_name while [x for x in store.find_package(new_name) if x != name]: new_name = "%s%s" % (onew_name, str(num)) num += 1 renamed.append((name, new_name)) store.rename_package(name, new_name) with open("renamed.pkl", "w") as pkl: pickle.dump(renamed, pkl) # Commit the changes store.commit() junk_names = bad_names() print("Found %s bad names" % len(junk_names))
for package in migrations["pypi-explicit"]: # Get all the users for this package users = [r["user_name"] for r in store.get_package_roles(package)] package_users[package] = users sent = [] # Email each user server = smtplib.SMTP(config.smtp_hostname) if config.smtp_starttls: server.starttls() if config.smtp_auth: server.login(config.smtp_login, config.smtp_password) for i, (package, users) in enumerate(package_users.iteritems()): fpackage = store.find_package(package) if not fpackage: continue package = fpackage[0] hosting_mode = store.get_package_hosting_mode(package) if hosting_mode != "pypi-scrape-crawl": continue users = sorted(set(users)) emails = [] for username in users: user = store.get_user(username)
} accepted_modes = { "pypi-scrape-crawl": ["pypi-scrape-crawl", "pypi-scrape", "pypi-explicit"], "pypi-scrape": ["pypi-scrape", "pypi-explicit"], "pypi-explicit": ["pypi-explicit"], } store.open() for desired_mode, names in data.iteritems(): if desired_mode == "pypi-scrape-crawl": continue # We don't need to do any processing for pypi-scrape-crawl for name in names: packages = store.find_package(name) if not packages: continue # This doesn't exist assert safe_name(name).lower() == safe_name(packages[0]).lower() name = packages[0] current_mode = store.get_package_hosting_mode(name) if current_mode not in accepted_modes[desired_mode]: store.set_package_hosting_mode(name, desired_mode) processed[desired_mode].add(name) store.commit() with open("migrated.pkl", "wb") as pkl: pickle.dump(processed, pkl)