Merge lp:~bjornt/landscape-client/apt-get-packages-versions into lp:~landscape/landscape-client/trunk

Proposed by Björn Tillenius
Status: Merged
Approved by: Free Ekanayaka
Approved revision: 435
Merged at revision: 376
Proposed branch: lp:~bjornt/landscape-client/apt-get-packages-versions
Merge into: lp:~landscape/landscape-client/trunk
Prerequisite: lp:~bjornt/landscape-client/apt-get-packages-by-name
To merge this branch: bzr merge lp:~bjornt/landscape-client/apt-get-packages-versions
Reviewer Review Type Date Requested Status
Free Ekanayaka (community) Approve
Jerry Seutter (community) Approve
Review via email: mp+78972@code.launchpad.net

Description of the change

Change AptFacade.get_packages() to return one object per version of a
package, so that we can report all the installed and available package
versions.

To post a comment you must log in.
Revision history for this message
Jerry Seutter (jseutter) wrote :

+1, looks good.

[1]
 + def is_package_available(self, version):
 """Is the package available for installation?"""

is_package_available is only checking if the specific version of the package is available. The docstring/method name could be a bit more precise. This also may be nitpicking :)

I guess this raises a bigger question: Is a version a package? I'm curious because get_package_by_name returns a version...

review: Approve
435. By Björn Tillenius

Merge trunk.

Revision history for this message
Free Ekanayaka (free.ekanayaka) wrote :

Looks good, +1!

[1]

     def get_packages(self):
         """Get all the packages available in the channels."""
- return self._pkg2hash.keys()
+ return self._hash2pkg.values()

I believe get_packages is mostly used to iterate over the available packages, maybe we can replace or add an iter_packages() method returning self._hash2pkg.itervalues() and saving some memory/CPU.

[2]

+ return [
+ version for version in self.get_packages()
+ if version.package.name == name]

Maybe this method is only used in tests, but if not we might want to create an index as well to improve performance.

review: Approve
Revision history for this message
Björn Tillenius (bjornt) wrote :

> Looks good, +1!
>
> [1]
>
> def get_packages(self):
> """Get all the packages available in the channels."""
> - return self._pkg2hash.keys()
> + return self._hash2pkg.values()
>
> I believe get_packages is mostly used to iterate over the available packages,
> maybe we can replace or add an iter_packages() method returning
> self._hash2pkg.itervalues() and saving some memory/CPU.

Sure, makes sense. I think it would be better to simply return itervalues() from there, though, no need to add another method.
>
> [2]
>
> + return [
> + version for version in self.get_packages()
> + if version.package.name == name]
>
> Maybe this method is only used in tests, but if not we might want to create an
> index as well to improve performance.

I'll go through the callsites to see if it makes sense.

Revision history for this message
Björn Tillenius (bjornt) wrote :

> +1, looks good.
>
>
> [1]
> + def is_package_available(self, version):
> """Is the package available for installation?"""
>
> is_package_available is only checking if the specific version of the package
> is available. The docstring/method name could be a bit more precise. This
> also may be nitpicking :)
>
> I guess this raises a bigger question: Is a version a package? I'm curious
> because get_package_by_name returns a version...

So, this is a bit of a mismatch between smart an apt. In smart a package is a specific version of a package, where in apt, a package is a container that has a list of available versions. It would probably be good to try to clean it up, but it would be better to do that after dropping smart, since renaming methods before that would make the migration work harder.

436. By Björn Tillenius

Return an iterator from get_packages() to save memory.

Subscribers

People subscribed via source and target branches

to all changes: