Regular Expression for Versions

I'm writing that Python script for updating/installing the newest GNOME
sources (btw, the pre-pre-pre-pre-before-that-even-alpha is up on, but please don't expect much of it, as
it doesn't do much yet (just downloads the files in one FTP directory),
and the code needs to be cleaned up, since it's my first Python script).

I need a better regular expression for matching the versions and package
names from a tarball/RPM name.

I'm using -(\d.)+\. now... it matches -1.0.58. from
gnome-libs-1.0.58.tar.gz for example, then I strip off the leading - and
trailing . .  This is ALSO my first time trying to use regular
expressions, so I fear I'm not doing too good of a job.  ;-)  Some
packages, like gdm-2.0beta4.tar.gz and gnome-hack_1.0.1-1.tar.gz fail.
I need a way of also grabbing that last number following a - , and a way
of grabbing stuff after a pre or beta or whatever (like the gdm
example).  This would make the version grabbing a lot easier.  Then I
could do stuff like comparing the current versions in the directory with
the file to be downloaded to see if the one you have is newer (like most
of my files, since I only work with the development packages).

Of course, it's going to be capable of recursing into directories, so
you can grab /pub/GNOME/unstable/sources for example and get the files
in the directories... the script can already be given files to skip and
handle that correctly.

Anyways, if anyone can help with that regular expression stuff, I could
finish up the script, since the download part doesn't have much left to
it (the install part may/may not be a bit more difficult).

Sean Middleditch

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