Changelog enhancements

James Westby jw+debian at jameswestby.net
Wed Nov 22 19:02:44 CET 2006


[Apologies if you get this twice, I wasn't sure if you were subscribed,
I am by the way, so feel free to just post to the list in future.]

On (21/11/06 23:14), John Wright wrote:
> Hi James,
> 
> I've been hacking on changelog.py, and I've got a couple changes you
> might be interested in.

Wow, thanks a lot for this. There's some nice stuff here.

> 
> First, I thought it'd be a good thing, since a bunch of methods in the
> Changelog class are just getters/setters, to expose those methods as
> attributes instead, using Python "properties".  Now, instead of
> 
>     v = cl.version() # get the version
>     cl.set_version(Version('1.3.5-2'))
> 
> you can do something like
> 
>     v = cl.version
>     cl.version = '1.3.5-2'

I thought about doing this, but I was moving really slowly on doing
anything and Enrico was keen to upload, so I didn't want to start
messing around in things I don't really understand

> 
> (Note, I've also made the version setter create a Version instance from
> its argument, and I've modified Version to be able to accept another
> Version instance or any object implementing __str__ to initialize.)
> 
> While I was playing with this, I realized that it might be confusing for
> people that Version instances are mutable, but that changing any of the
> attributes doesn't update other affected ones.  (For example, if I
> change v.debian_version, v.full_version doesn't include the new debian
> revision.)

I hadn't thought of that, thanks. I agree it is broken.

> 
> I guess there are a couple good ways to handle this.  The one I picked
> was to expose the attributes through properties which only implement a
> get method, effectively making the objects immutable.  Another way, of
> course, would be to add more logic to the class, perhaps by storing each
> part of the version separately, and having the full_version attribute
> actually call a method that reconstructs the version.
> 

I think mutable might be better, but I'm from a Java background where I
would have made them immutable. 

> 
> I also added an __eq__ method to the Version class.  It might be cool in
> the future to have a full __cmp__ method, perhaps like the one in
> debian_support.py, or perhaps to use apt_pkg.VersionCompare if apt_pkg
> is available.

I would like to use the debian_support objects, and I can't really
remember why I didn't. I should look in to transitioning over. I think
it might have been that you can't get the parts out of the whole number.
I think it's a bad idea to have two classes in the same package that
serve the same purpose, it's more of a historical reason.

> 
> I've attached a python bundle of my changes to the trunk.  The branch
> also exists at
>     http://alioth.debian.org/~jsw-guest/python-debian/
> 
> I hope this is helpful!  Of course I'll understand if you don't think
> it's worth including, since it's not really much of a feature
> enhancement. :)
> 

I'm more than happy for you to commit your changes direct, as there not
even an API breakage. I believe you have the permissions now.

I plan to send a mail to the list with my thoughts on the packaging
later, and in that I was going to mention others committing.

Thanks very much,

James

-- 
  James Westby   --    GPG Key ID: B577FE13    --     http://jameswestby.net/
  seccure key - (3+)k7|M*edCX/.A:n*N!>|&7U.L#9E)Tu)T0>AM - secp256r1/nistp256




More information about the pkg-python-debian-discuss mailing list