Code review comment for lp:~blake-rouse/maas/add-version-to-ui

Revision history for this message
Gavin Panella (allenap) wrote :

A few comments (not a review):

- Instead of searching for a particular package name, how about
  searching for the package that owns the current file? That's more
  likely to be correct *and* it reduces the coupling between upstream
  and the package. For example:

    import inspect
    from os.path import realpath

    import apt

    def find_package_of(cache, filename):
        # This is quicker than you might think.
        for pkg in cache:
            if pkg.is_installed:
                if filename in pkg.installed_files:
                    return pkg

    cache = apt.Cache()
    source = inspect.getsourcefile(find_package_of)
    package = find_package_of(cache, realpath(source))
    if package is None:
        pass # Check for branch info.
    else:
        installed = package.installed
        # Use the *source* package name and version.
        desc = "%s %s" % (installed.source_name, installed.source_version)

- When reporting the branch version, also include the branch's location,
  or its name. This is less important to the developer, but could be
  very useful in screen-grabs, for example.

« Back to merge proposal