aclark4life / vanity

Get package download statistics from PyPI
GNU General Public License v2.0
66 stars 14 forks source link

Sort JSON results #16

Closed aclark4life closed 8 years ago

aclark4life commented 9 years ago

The XML-RPC API code in vanity seems overly complicated, yet is at least sorting the results correctly whereas the JSON implementation is not. Here's an overview of the process:

If JSON, release_data does this::

    if protocol:
        for package in packages:
            data = get_jsonparsed_data(PYPI_JSON % package)
            for release in data['releases']:
                urls = data['releases'][release]
                yield urls, data['info']
        return

If not, release_data calls package_releases which does this:

def package_releases(packages):
    """
    """
    mcall = xmlrpc.MultiCall(PYPI_XML)
    called_packages = deque()
    for package in packages:
        mcall.package_releases(package, True)
        called_packages.append(package)
        if len(called_packages) == 100:
            result = mcall()
            mcall = xmlrpc.MultiCall(PYPI_XML)
            for releases in result:
                yield called_packages.popleft(), releases
    result = mcall()
    for releases in result:
        yield called_packages.popleft(), releases

So perhaps the challenge is to deque the JSON results, but I failed in trying to get that to work as expected. The "real" issue is a convoluted data model and possibly differing results from different protocols (as far as I can tell.)

aclark4life commented 9 years ago

@hugovk In case you get bored ^^^ :grinning:

aclark4life commented 8 years ago

@mattjegan in case you get bored, too ^^^ :smile:

mattjegan commented 8 years ago

Fixed the JSON sorting issue at this pull request