Source

pythonwise / pkg-urls.py

#!/usr/bin/env python
'''Show download url for installed packages.'''

from pip.util import get_installed_distributions


def download_url(dist):
    '''Get download url from distribution PKG-INFO file.'''
    for line in dist._get_metadata('PKG-INFO'):
        if line.startswith('Download-URL:'):
            return line.split(':', 1)[1]


def main(argv=None):
    import sys
    from argparse import ArgumentParser

    argv = argv or sys.argv

    parser = ArgumentParser(
        description='show download urls for installed packages')
    parser.add_argument('--unknown', help='show unknown urls',
                        action='store_true', default=False)
    args = parser.parse_args(argv[1:])

    for dist in get_installed_distributions():
        url = download_url(dist)
        if url or args.unknown:
            print('{}: {}'.format(dist.project_name, url or 'UNKNOWN'))


if __name__ == '__main__':
    main()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.