Skip to content

Rework all info-like functions to use get_info() #7

Open
@maphew

Description

@maphew

With 32fbd7b we have a working info command, and a get_info() function which builds a dictionary of useful attributes. Now we have the necessary plumbing to rework all the functions which go out one by one to fetch and build the attributes one at a time into simple lookups from the dict.

So instead of calling on 3 chained functions

def ball(packages):
    '''Print full local path name of package archive '''
    print "\n%s = %s" % (p, get_ball(p))

def get_ball (packagename):
    url, md5 = get_url (packagename)
    return '%s/%s' % (downloads, url)

def get_url (packagename):
    if not dists[distname].has_key (packagename) \
   ...~20 lines snipped...
    return filename, md5

we can just do

pkg_info = get_info(pkg)
print pkg_info['ball']

A delightful collapse in complexity which should make understanding and working on this program a whole lot easier and more enjoyable!

Before going to deep into touching all the info-like functions we should spend some time thinking about building a nested list/dictionary one level higher. Get_info() gives us a dict for each package, one at a time. Should we also build a list-of-pkg-dicts for everything all in one go?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions