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

Class ParseProcessor

lantz/processors.py:227–248  ·  view source on GitHub ↗

Processor to convert/parse the function parameters. The syntax is equal to `Processor` except that strings are interpreted as a :class:Parser expression. >>> conv = ParseProcessor('spam {:s} eggs') >>> conv('spam ham eggs') 'ham' >>> conv = ParseProcessor((

Source from the content-addressed store, hash-verified

225
226
227class ParseProcessor(Processor):
228 """Processor to convert/parse the function parameters.
229
230 The syntax is equal to `Processor` except that strings are interpreted
231 as a :class:Parser expression.
232
233 >>> conv = ParseProcessor('spam {:s} eggs')
234 >>> conv('spam ham eggs')
235 'ham'
236
237 >>> conv = ParseProcessor(('hi {:d}', 'bye {:s}'))
238 >>> conv(('hi 42', 'bye Brian'))
239 (42, 'Brian')
240
241 """
242
243 @classmethod
244 def to_callable(cls, obj):
245 if isinstance(obj, str):
246 return Parser(obj)
247 raise TypeError('parse_params argument must be a string or a callable, '
248 'not {}'.format(obj))
249
250
251class MapProcessor(Processor):

Callers 2

parse_queryMethod · 0.90
parse_queryMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected