Project

General

Profile

« Previous | Next » 

Revision 6223

xml_func.py: Removed no longer used _map(), which has been replaced by a corresponding DB function

View differences:

lib/xml_func.py
227 227

  
228 228
#### Transforming values
229 229

  
230
def repl(repls, value):
231
    '''Raises error if value not in map and no special '*' entry
232
    @param repls dict repl:with
233
        repl "*" means all other input values
234
        with "*" means keep input value the same
235
        with "" means ignore input value
236
    '''
237
    try: new_value = repls[value]
238
    except KeyError, e:
239
        # Save traceback right away in case another exception raised
240
        fe = FormatException(e)
241
        try: new_value = repls['*']
242
        except KeyError: raise fe
243
    if new_value == '*': new_value = value # '*' means keep input value the same
244
    return new_value
245

  
246
def _map(items, node):
247
    '''See repl()
248
    @param items
249
        <last_entry> Value
250
        <other_entries> name=value Mappings. Special values: See repl() repls.
251
    '''
252
    value = pop_value(items)
253
    if value == None: return None # input is empty
254
    return util.none_if(repl(dict(items), value), u'') # empty value means None
255
funcs['_map'] = _map
256

  
257 230
def _replace(items, node):
258 231
    items = conv_items(strings.ustr, items) # get *once* from iter, check types
259 232
    value = pop_value(items)

Also available in: Unified diff