You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Rework all info-like functions to use get_info() #7
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?
when converting apt url to get_info() this morning I realized most of the lightweight info functions could be generalized into a single function along the lines of:
def info(subcommand, packages):
if not packages:
help(//subcommand//)
sys.stderr.write('No package specified. Try running "apt list"')
return
for p in packages:
print '%-20s%-12s' % (p, get_info(p)[//subcommand//])
Really the only thing that changes from function to function (for many) is the docstring and how the information is reported to the user. In the end though, it may this last item that dictates keeping the separate functions.
this is postponed until after #35, clarifying the internal data model, because get_info right now doesn't properly distinguish between installed info and setup.ini info.
Activity
setup-parser.py: towards setup.ini as py object
maphew commentedon Jan 10, 2015
when converting
apt urlto get_info() this morning I realized most of the lightweight info functions could be generalized into a single function along the lines of:Really the only thing that changes from function to function (for many) is the docstring and how the information is reported to the user. In the end though, it may this last item that dictates keeping the separate functions.
Something to think about anyway.
maphew commentedon Apr 4, 2015
this is postponed until after #35, clarifying the internal data model, because get_info right now doesn't properly distinguish between installed info and setup.ini info.