On Mon, 27 Apr 2009 09:36:24 -0700, Trent Mick <trentm@gmail.com> wrote:
Can a constructor which takes each part of the version data as a separate object be added?
Sounds good, I'd be in favor of making RationalVersion using explicit version bits, and having some kind of function:
str2version(somestring) -> RationalVersion instance
Or we could have:
RationalVersion(...version bits...) RationalVersion.from_string(s) # this is a @classmethod
I like the sound of that.
I have pushed the prototype in a bitbucket project so everyone can work it out (just join the project)
Thanks for putting this up.
If we provide a way to construct a RationalVersion with version bits, then we need to discuss what those "version bits" look like. Currently the internal tuple data structure (`self.info`) looks like this (from verlib.py's description of the 'f' marker used to help with sort ordering, http://bitbucket.org/tarek/distutilsversion/src/cc93f5e1df3f/verlib.py#cl-16...):
# A marker used in the second and third parts of the `info` tuple, for # versions that don't have those segments, to sort properly. A example # of versions in sort order ('highest' last): # 1.0b1 ((1,0), ('b',1), ('f',)) # 1.0.dev345 ((1,0), ('f',), ('dev', 345)) # 1.0 ((1,0), ('f',), ('f',)) # 1.0.post345 ((1,0), ('f',), ('post', 345)) # ^ ^ # 'f' < 'b' -------------/ | # | # 'dev' < 'f' < 'post' -----------/ # Other letters would do, bug 'f' for 'final' is kind of nice.
Is this what we would want the constructor to take?
RationalVersion( (1,0), ('b', 1) ) # 1.0b1 RationalVersion( (1,0), ('f',), ('post', 345) ) # 1.0.post345
It seems a little too low-level. We could allow something a little nicer:
RationalVersion( (1, 0, 'b', 1) ) # 1.0b1 RationalVersion( (1, 0, 'post', 345) ) # 1.0.post345
If we did this, then we'd probably want these attributes on RationalVersion:
v = RationalVersion((1,0,'b',1)) str(v) '1.0b1' v.info (1, 0, 'b', 1) v._cmp_info # use for comparison ((1, 0), ('b', 1), ('f',))
Thoughts?
I'd be in favor of replacing the 'b' and 'post' and so forth with symbolic constants - eg, RationalVersion((1, 0, RationalVersion.POST, 345)). If not that, then I'd at least like 'final' instead of 'f', 'beta' instead of 'b' (is that what 'b' means?) - since this doesn't necessarily need to be tied to how the version is serialized: it's for programmers to type, so the more obvious it is what things mean, the better. Jean-Paul