diff --git a/pisi/util.py b/pisi/util.py index 8e10f101..73c14e6d 100644 --- a/pisi/util.py +++ b/pisi/util.py @@ -18,10 +18,21 @@ class UtilError(Exception): # string/list functions +def concat(l): + """concatenate a list of lists""" + return reduce( lambda x,y: x+y, l ) + def strlist(l): """concatenate string reps of l's elements""" return string.join(map(lambda x: str(x) + ' ', l)) +def multisplit(str, chars): + """ split str with any of chars""" + l = [str] + for c in chars: + l = concat(map(lambda x:x.split(c), l)) + return l + def same(l): "check if all elements of a sequence are equal" if len(l)==0: diff --git a/pisi/version.py b/pisi/version.py index b298859e..064155e0 100644 --- a/pisi/version.py +++ b/pisi/version.py @@ -1,8 +1,10 @@ # version structure +import util + class Version: def __init__(self, verstring): - self.comps = verstring.split('.-') + self.comps = map(lambda x: int(x), util.multisplit(verstring,'.-')) def pred(self,rhs,pred): for i in range(0, len(comps)-1): diff --git a/tests/run.py b/tests/run.py index f9f873fe..8d2911e8 100755 --- a/tests/run.py +++ b/tests/run.py @@ -14,12 +14,14 @@ def run_all(): import archivetests import installdbtests import packagedbtests + import versiontests alltests = unittest.TestSuite(( specfiletests.suite, contexttests.suite, fetchertests.suite, archivetests.suite, + versiontests.suite, installdbtests.suite, packagedbtests. suite ))