Name | parameter-verification JSON |
Version |
0.1.1
JSON |
| download |
home_page | |
Summary | Simple function that can be used to validate a list of parameters |
upload_time | 2023-11-05 04:04:48 |
maintainer | |
docs_url | None |
author | |
requires_python | >=3.3 |
license | |
keywords |
verify
parameters
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Python Parameter Verification
Homepage: <a href="https://www.learningtopi.com/python-modules-applications/parameter_verification/">https://www.learningtopi.com/python-modules-applications/parameter_verification/<a>
This is a simple Python function that can be used to test variable types and values. The intended purpose is to check the parameters of a function to ensure that appropriate types and values have been passed.
The function is specifically written to support Python >=3.3 so it can be used with a wide array of applications. There are also no dependencies that need to be installed.
## Usage
from parameter_verification import verify_params, ParameterError
def test_function_1(param1, param2, param3, param4):
''' Sample function to show verify_params usage '''
try:
verify_params(param1=(param1,int), param2=(param2,str,'=abc'), param3=(param3,float, '>100.2', '<110.0'), param4=(param4,str,'len=4','=abcd'))
except ParameterError as e:
# some code to handle an exception if desired
# proceed with your function!
The verify_param function takes keyword arguments for each parameter to check. The value of each parameter is passed as a tuple consisting of:
- The value to check (i.e. the variable)
- The variable type to check against
- (optional) an additional check to perform (i.e. '>100.2' or '=abc')
- (optional) more additional checks can be added, i.e. '>100.2', '<110.0'
## Supported Checks
The following checks are supported (in addition to the data type which can be any Python type):
- '==' or '=': Both perform the same check and can be used interchangably
- '<', '<=', '>', '>=': Perform the typical checks
- 'len=x', 'len>x', 'len>=x', etc: Check the length of a string
## Returns and Errors
The function returns True if all parameters pass. If a parameter check fails, the function raises a ParameterError exception. If desired, this behavior can be changed by setting "no_raise=True". With no_raise set to True, False will be returned in the case of a failed parameter check rather than raising an exception.
Raw data
{
"_id": null,
"home_page": "",
"name": "parameter-verification",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.3",
"maintainer_email": "",
"keywords": "verify,parameters",
"author": "",
"author_email": "Thomas Dunteman <git@learningtopi.com>",
"download_url": "https://files.pythonhosted.org/packages/fa/c9/1f465b2a7e8d95ab56f7617468a11c5ce4b04eea3a3198a174990f926a5d/parameter_verification-0.1.1.tar.gz",
"platform": null,
"description": "# Python Parameter Verification\n\nHomepage: <a href=\"https://www.learningtopi.com/python-modules-applications/parameter_verification/\">https://www.learningtopi.com/python-modules-applications/parameter_verification/<a>\n\nThis is a simple Python function that can be used to test variable types and values. The intended purpose is to check the parameters of a function to ensure that appropriate types and values have been passed.\n\nThe function is specifically written to support Python >=3.3 so it can be used with a wide array of applications. There are also no dependencies that need to be installed.\n\n## Usage\n\n from parameter_verification import verify_params, ParameterError\n\n def test_function_1(param1, param2, param3, param4):\n ''' Sample function to show verify_params usage '''\n try:\n verify_params(param1=(param1,int), param2=(param2,str,'=abc'), param3=(param3,float, '>100.2', '<110.0'), param4=(param4,str,'len=4','=abcd'))\n except ParameterError as e:\n # some code to handle an exception if desired\n\n # proceed with your function!\n\nThe verify_param function takes keyword arguments for each parameter to check. The value of each parameter is passed as a tuple consisting of:\n\n- The value to check (i.e. the variable)\n- The variable type to check against\n- (optional) an additional check to perform (i.e. '>100.2' or '=abc')\n- (optional) more additional checks can be added, i.e. '>100.2', '<110.0'\n\n## Supported Checks\n\nThe following checks are supported (in addition to the data type which can be any Python type):\n\n- '==' or '=': Both perform the same check and can be used interchangably\n- '<', '<=', '>', '>=': Perform the typical checks\n- 'len=x', 'len>x', 'len>=x', etc: Check the length of a string\n\n## Returns and Errors\n\nThe function returns True if all parameters pass. If a parameter check fails, the function raises a ParameterError exception. If desired, this behavior can be changed by setting \"no_raise=True\". With no_raise set to True, False will be returned in the case of a failed parameter check rather than raising an exception.\n",
"bugtrack_url": null,
"license": "",
"summary": "Simple function that can be used to validate a list of parameters",
"version": "0.1.1",
"project_urls": {
"bug tracker": "https://github.com/LearningToPi/parameter_verification/issues",
"homepage": "https://www.learningtopi.com/python-modules-applications/parameter_verification",
"source code": "https://github.com/LearningToPi/parameter_verification"
},
"split_keywords": [
"verify",
"parameters"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "87e413616b077945baa89fb12c43b20e1e9897bb148bb906a0c9d471735bbcb2",
"md5": "2aaced6f9b6167a0657a2c5fa35ddce2",
"sha256": "1a8d410f905d3ef1690501396de5d351ccc00eddd174b8fafb3243a1c0be00f2"
},
"downloads": -1,
"filename": "parameter_verification-0.1.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "2aaced6f9b6167a0657a2c5fa35ddce2",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.3",
"size": 4569,
"upload_time": "2023-11-05T04:04:46",
"upload_time_iso_8601": "2023-11-05T04:04:46.789326Z",
"url": "https://files.pythonhosted.org/packages/87/e4/13616b077945baa89fb12c43b20e1e9897bb148bb906a0c9d471735bbcb2/parameter_verification-0.1.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "fac91f465b2a7e8d95ab56f7617468a11c5ce4b04eea3a3198a174990f926a5d",
"md5": "025d03599ebfedf82f0981f8005a7516",
"sha256": "77e68372024ff5004241994f2c3b7eb101f2ca84addd5f91f92a738cf8768452"
},
"downloads": -1,
"filename": "parameter_verification-0.1.1.tar.gz",
"has_sig": false,
"md5_digest": "025d03599ebfedf82f0981f8005a7516",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.3",
"size": 4139,
"upload_time": "2023-11-05T04:04:48",
"upload_time_iso_8601": "2023-11-05T04:04:48.346497Z",
"url": "https://files.pythonhosted.org/packages/fa/c9/1f465b2a7e8d95ab56f7617468a11c5ce4b04eea3a3198a174990f926a5d/parameter_verification-0.1.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-11-05 04:04:48",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "LearningToPi",
"github_project": "parameter_verification",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "parameter-verification"
}