[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#733489: Remaining patches for bug #733489



On 08/20/2015 10:07 PM, Julian Andres Klode wrote:
On Thu, Aug 20, 2015 at 09:58:11PM +0200, Michael Schaller wrote:

Hi Michael, I think it looks OK, but let me suggest some
changes:

- Drop the parent_version property and use _version directly
- Drop the cache property and use _cache directly
- Drop the TargetVersionList. AFAIK, the only thing different
   is it wrapping the list representation in a <TargetVersionList>
   thing, this does not seem to be needed (there's no point
   creating our own list type just for some corner-case
   cosmetic issue).

Then the patch will be much smaller, and still be able to do
the same.


I can remove the 'parent_version' and 'cache' properties but would like to know your reasoning. From my point of view these properties just make the code more consistent with the other properties that are already there. It is unfortunate though that I can't name the 'parent_version' property 'version' as that would be even more consistent.

I would also like to keep the 'TargetVersionList' class as I quite often use the interactive Python console with python-apt during development and there it helps a lot to have a good '__repr__' implementation.

Take for an example this interactive Python session. I've replaced '>>> ' with a newline for better readability/mailability.

$ python
 import apt

cache = apt.Cache()

cache
<apt.cache.Cache object at 0x7fef993d6210>

pkg = cache['bash']

pkg
<Package: name:'bash' architecture='amd64' id:738L>

pkg.cache
<apt.cache.Cache object at 0x7fef993d6210>

ver = pkg.installed

ver
<Version: package:'bash' version:'4.3-11ubuntu2'>

ver.package
<Package: name:'bash' architecture='amd64' id:738L>

deps = ver.get_dependencies('Depends')

deps
[<Dependency: [<BaseDependency: name:'base-files' relation:'>=' version:'2.1.12' rawtype:'Depends'>]>, <Dependency: [<BaseDependency: name:'debianutils' relation:'>=' version:'2.15' rawtype:'Depends'>]>]

deps[0]
<Dependency: [<BaseDependency: name:'base-files' relation:'>=' version:'2.1.12' rawtype:'Depends'>]>

deps[0].parent_version
<Version: package:'bash' version:'4.3-11ubuntu2'>

deps[0].target_versions
<TargetVersionList: "[<Version: package:'base-files' version:'7.2ubuntu9'>, <Version: package:'base-files:i386' version:'7.2ubuntu9'>]">


BTW: From my point of view 'Version.__repr__' should also include the architecture and the 'id' in 'Package.__repr__' is rather useless.

Julian, what do you think?


Reply to: