Python Forum

Full Version: Mass-update pip pkgs
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Here is a program I wrote to mass-update pip packages. It relies on pip-review and another module I wrote to make numbered lists.

import numli
import os


def pkg_update():
    """Update pip packages."""
    options = ['Yes', 'Exit']
    numli.addnum(options)
    check = input('Check for updates? ')

    if check in '1':
        print('Checking for updates.')
        os.system('pip list -o')

        os.system('pip-review --local --interactive')
        pkg_update()

    elif check in '2':
        raise SystemExit

    else:
        pkg_update()


if __name__ == "__main__":
    pkg_update()
Here is the list numbering module. I got tired of typing out the for loop every time.
def addnum(num):
    """Add numbers to a list"""
    for c, value in enumerate(num, 1):
        print(c, value)

if __name__ == "__main__":
    addnum(num)