* 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:
Eray Özkural
2005-06-21 11:34:39 +00:00
parent 6b390fe7e0
commit 5547bcf68d
3 changed files with 16 additions and 1 deletions
+11
View File
@@ -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
View File
@@ -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):
+2
View File
@@ -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
))