* seq/string utility'leri implement et:
- concat, listeleri birlestir - multisplit, string.split 'i extend et * version class'ini tamir et ve testi gecirt
This commit is contained in:
@@ -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:
|
||||
|
||||
+3
-1
@@ -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):
|
||||
|
||||
@@ -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
|
||||
))
|
||||
|
||||
Reference in New Issue
Block a user