MCPcopy Create free account
hub / github.com/LabPy/lantz / MapProcessor

Class MapProcessor

lantz/processors.py:251–272  ·  view source on GitHub ↗

Processor to map the function parameter values. The syntax is equal to `Processor` except that a dict is used as mapping table. Examples:: >>> conv = MapProcessor({True: 42}) >>> conv(True) 42

Source from the content-addressed store, hash-verified

249
250
251class MapProcessor(Processor):
252 """Processor to map the function parameter values.
253
254 The syntax is equal to `Processor` except that a dict is used as
255 mapping table.
256
257 Examples::
258
259 >>> conv = MapProcessor({True: 42})
260 >>> conv(True)
261 42
262
263 """
264
265 @classmethod
266 def to_callable(cls, obj):
267 if isinstance(obj, dict):
268 return get_mapping(obj)
269 if isinstance(obj, set):
270 return check_membership(obj)
271 raise TypeError('MapProcessor argument must be a dict or a callable, '
272 'not {}'.format(obj))
273
274
275class ReverseMapProcessor(Processor):

Callers 2

rebuildMethod · 0.85
rebuildMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected