Welcome to EvArgs

“EvArgs” is a Python module designed for value assignment, easy expression parsing, and type casting. It validates values based on defined rules and offers flexible configuration along with custom validation methods.

Github

The latest version and documentation may be found on GitHub. The Github URL is the following.

EvArgs Github

Install

$ pip install evargs
or
$ pip3 install evargs

Features and documentation

“EvArgs” provides the following features.

  • It can specify the condition or value-assignment using a simple expression. e.g. a=1;b>5;c=>1;c<10;

  • Evaluate assigned values. e.g evargs.evaluate(‘a’, 1)

  • Type cast - str, int, float, complex, Enum class, custom function…

  • Value validation - unsigned, number range, alphabet, regex, any other…

  • Put values. It’s available to using put is without parsing the expression.

  • Applying multiple validations.

  • Applying Pre-processing method and Post-processing method.

  • Get assigned values.

  • Make parameter’s description.

  • Other support methods for value-assignment.

And you can see detail features and usage in EvArgs documentation

Modules and Classes reference

The following is the documentation for the module and class. Github source

EvArgs class document

Usage

from evargs import EvArgs

v = evargs.assign(' 1 ', cast=str, trim=True)
v = evargs.assign('1', cast=int, validation=('range', 1, 10))

v = evargs.assign_values({'a': {'cast': int}, 'b': {'cast': int}}, {'a': '1', 'b': '2'})

evargs.assign('1.5', cast=float, name='var1')
print(evargs.get('var1'))
from evargs import EvArgs

evargs.initialize({
   'a': {'cast': int},
   'b': {'cast': int, 'list': True}
})

evargs.put('a', 1)
evargs.put('b', [7, 8, 9])
from evargs import ExpEvArgs

evargs = ExpEvArgs()

evargs.initialize({
  'a': {'cast': bool},
  'b': {'cast': int},
  'c': {'cast': int},
  'd': {'cast': float, 'default': 3.14},
  'e': {'cast': str},
  'f': {'cast': int, 'multiple': True},
})

evargs.parse('a=1;b>=5;c=10;d=;e=H2O;f>=5;f<100')

print(evargs.get('a'), evargs.evaluate('a', True))
print(evargs.get('b'), evargs.evaluate('b', 8))
print(evargs.get('c'), evargs.evaluate('c', 10))
print(evargs.get('d'), evargs.evaluate('d', 3.14))
print(evargs.get('e'), evargs.evaluate('e', 'H2O'))
print(evargs.evaluate('f', 50))