Project

General

Profile

« Previous | Next » 

Revision 1399

xml_func.py: Added _rangeStart and _rangeEnd

View differences:

lib/xml_func.py
164 164
    return str(to - from_)
165 165
funcs['_range'] = _range
166 166

  
167
def parse_range(str_, range_sep='-'):
168
    default = (str_, None)
169
    start, sep, end = str_.partition(range_sep)
170
    if sep == '': return default # not a range
171
    return tuple(d.strip() for d in (start, end))
172

  
173
def _rangeStart(items):
174
    items = dict(conv_items(str, items))
175
    try: value = items['value']
176
    except KeyError, e: raise SyntaxException(e)
177
    return parse_range(value)[0]
178
funcs['_rangeStart'] = _rangeStart
179

  
180
def _rangeEnd(items):
181
    items = dict(conv_items(str, items))
182
    try: value = items['value']
183
    except KeyError, e: raise SyntaxException(e)
184
    return parse_range(value)[1]
185
funcs['_rangeEnd'] = _rangeEnd
186

  
167 187
def _avg(items):
168 188
    count = 0
169 189
    sum_ = 0.

Also available in: Unified diff