param-info 0.2.1

Last updated:

0 purchases

param-info 0.2.1 Image
param-info 0.2.1 Images
Add to Cart

Description:

paraminfo 0.2.1

A python package for parsing parameters

Usage
>>> from param_info import *
>>> params = ParamList()
>>> params.add( ParamInfoInt("a1",7,min=5) )
>>> params.add( ParamInfoVal("a2",['aa','bb','cc']) )
>>> params.add( ParamInfoStr("a3",' hallo ') )
>>> def doSomething(param,values):
... if params.validate(values):
... # Do something with values
... for name,param in params.params.items():
... print( '{0} ==> {1}'.format(name,param.value))
... else:
... # Handle errors
... for name,param in params.errors.items():
... print( 'Error. {0} ==> {1}'.format(name,param.errorText))
>>> doSomething(params,{'a1':3})
Error. a1 ==> a1=3 should be integer >= 5
Error. a2 ==> a2 is required
>>> doSomething(params,{'a1':8,'a2':'bb'})
a1 ==> 8
a2 ==> bb
a3 ==> hallo
>>> doSomething(params,{'a2':'zz'})
Error. a2 ==> a2=zz should be one of ['aa', 'bb', 'cc']
>>> doSomething(params,{'a2':'aa','a3':'hola'})
a1 ==> 7
a2 ==> aa
a3 ==> hola

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Customer Reviews

There are no reviews.