Improve Select DataVars

master3.3
Mike Hiretsky 12 years ago
parent 7e4146a4d0
commit a4410b2e4a

@ -1288,17 +1288,20 @@ class DataVars(SimpleDataVars):
else:
filterFunc = lambda x:x
if not type(where) in (tuple,list):
where = [where]
woffset = len(where)
if type(selField) in (tuple,list):
count = len(selField)
mapFunc = lambda x:x[1:]
count = len(selField)+woffset
mapFunc = lambda x:x[woffset:]
res = filter(filterFunc,
zipVars(where,*selField))
zipVars(*(where+selField)))
else:
count = 1
fields = [where,selField]
mapFunc = lambda x:x[1]
count = 1+woffset
fields = where+[selField]
mapFunc = lambda x:x[woffset]
res = filter(filterFunc,
zipVars(where,selField))
zipVars(*fields))
if sort:
if "/" in sort:
sort,sortkey = sort.split('/')
@ -1306,7 +1309,7 @@ class DataVars(SimpleDataVars):
res.sort(key=sortkey,reverse=True if sort == "DESC" else False)
if limit == 1:
if not any(res):
res = [[""]*(count+1)]
res = [[""]*(count)]
return mapFunc(res[0])
else:
return map(mapFunc,res[:limit])

Loading…
Cancel
Save