argreq/__init__.py
def requirement(
    expression : str,
    required : bool = True
):
    '''Test a general requirement for function argument(s)
    :param expression: a valid python expression using `{arg_name}` to specify the function arguments to test, for example: `{a}>{b}`,`{item} in {a}.values()`, etc.
    :param required: bool, Optional. If set to true and one the arguments mentioned in the expression is missing, raising `argreq.errors.ArgumentNotFoundError`.
    
    :raises: `argreq.errors.NotMetRequirementError`, `argreq.errors.ArgumentNotFoundError`
    '''
    def decorator(func):
        @functools.wraps(func)
        def wrapper(*args, **kwargs):
            search_res = VAR_NAMES_NON_EMPTY_PATTERN.findall(expression)
            format_kwargs = {}
            should_eval = True
            for _, arg_name in search_res:
                try:
                    format_kwargs[arg_name] = _find_argument(func, arg_name, args, kwargs)
                except argreq.errors.ArgumentNotFoundError as e:
                    if required:
                        raise e
                    else:
                        should_eval = False
                        break
            if should_eval:
                _exp = expression.format(**format_kwargs)
                if not eval(_exp):
                    raise argreq.errors.NotMetRequirementError(requirement, _exp)
            return func(*args, **kwargs)
        return wrapper
    return decorator
Test a general requirement for function argument(s)
    :param expression: a valid python expression using `{arg_name}` to specify the function arguments to test, for example: `{a}>{b}`,`{item} in {a}.values()`, etc.
    :param required: bool, Optional. If set to true and one the arguments mentioned in the expression is missing, raising `argreq.errors.ArgumentNotFoundError`.
    
    :raises: `argreq.errors.NotMetRequirementError`, `argreq.errors.ArgumentNotFoundError`
    
Test a general requirement for function argument(s)
Test a general requirement for function argument ( s )
def requirement(
    expression : str,
    required : bool = True
):
    def decorator(func):
        @functools.wraps(func)
        def wrapper(*args, **kwargs):
            search_res = VAR_NAMES_NON_EMPTY_PATTERN.findall(expression)
            format_kwargs = {}
            should_eval = True
            for _, arg_name in search_res:
                try:
                    format_kwargs[arg_name] = _find_argument(func, arg_name, args, kwargs)
                except argreq.errors.ArgumentNotFoundError as e:
                    if required:
                        raise e
                    else:
                        should_eval = False
                        break
            if should_eval:
                _exp = expression.format(**format_kwargs)
                if not eval(_exp):
                    raise argreq.errors.NotMetRequirementError(requirement, _exp)
            return func(*args, **kwargs)
        return wrapper
    return decorator
def requirement ( expression : str , required : bool = True ) : def decorator ( func ) : @ functools . wraps ( func ) def wrapper ( * args , ** kwargs ) : search_res = VAR_NAMES_NON_EMPTY_PATTERN . findall ( expression ) format_kwargs = { } should_eval = True for _ , arg_name in search_res : try : format_kwargs [ arg_name ] = _find_argument ( func , arg_name , args , kwargs ) except argreq . errors . ArgumentNotFoundError as e : if required : raise e else : should_eval = False break if should_eval : _exp = expression . format ( ** format_kwargs ) if not eval ( _exp ) : raise argreq . errors . NotMetRequirementError ( requirement , _exp ) return func ( * args , ** kwargs ) return wrapper return decorator
Test a general requirement for function argument(s)
Test a general requirement for function argument ( s )
'''Test a general requirement for function argument(s)
    :param expression: a valid python expression using `{arg_name}` to specify the function arguments to test, for example: `{a}>{b}`,`{item} in {a}.values()`, etc.
    :param required: bool, Optional. If set to true and one the arguments mentioned in the expression is missing, raising `argreq.errors.ArgumentNotFoundError`.
    
    :raises: `argreq.errors.NotMetRequirementError`, `argreq.errors.ArgumentNotFoundError`
    '''
None
expression
str
a valid python expression using `{arg_name}` to specify the function arguments to test, for example: `{a}>{b}`,`{item} in {a}.values()`, etc.
a valid python expression using ` { arg_name } ` to specify the function arguments to test for example : ` { a } > { b } ` ` { item } in { a } . values () ` etc .
required
bool
bool, Optional. If set to true and one the arguments mentioned in the expression is missing, raising `argreq.errors.ArgumentNotFoundError`.
bool Optional . If set to true and one the arguments mentioned in the expression is missing raising ` argreq . errors . ArgumentNotFoundError ` .