Name | optioner JSON |
Version |
1.5.2
JSON |
| download |
home_page | None |
Summary | Argument Parser |
upload_time | 2024-04-12 20:35:29 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.9 |
license | MIT License Copyright (c) 2024 Soumyo Deep Gupta Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
keywords |
d33pster
optioner
argument-parser
argument
parser
argparse
|
VCS |
|
bugtrack_url |
|
requirements |
pytest
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# optioner
[![Continuous Deployment](https://github.com/d33pster/optioner/actions/workflows/cont-dep.yml/badge.svg)](https://github.com/d33pster/optioner/actions/workflows/cont-dep.yml)
[![Feature Tests](https://github.com/d33pster/optioner/actions/workflows/pytest.yml/badge.svg)](https://github.com/d33pster/optioner/actions/workflows/pytest.yml)
[![Build status](https://ci.appveyor.com/api/projects/status/qoaeiypaxnonrosv?svg=true)](https://ci.appveyor.com/project/d33pster/optioner)
[![codecov](https://codecov.io/gh/d33pster/optioner/graph/badge.svg?token=NE6E28GWCK)](https://codecov.io/gh/d33pster/optioner)
![PyPI - Version](https://img.shields.io/pypi/v/optioner)
![Python Version from PEP 621 TOML](https://img.shields.io/python/required-version-toml?tomlFilePath=https%3A%2F%2Fraw.githubusercontent.com%2Fd33pster%2Foptioner%2Fmain%2Fpyproject.toml)
![PyPI - Wheel](https://img.shields.io/pypi/wheel/optioner)
![Dependents (via libraries.io)](https://img.shields.io/librariesio/dependents/pypi/Optioner)
![GitHub License](https://img.shields.io/github/license/d33pster/optioner)
![GitHub last commit](https://img.shields.io/github/last-commit/d33pster/optioner)
<br>
<p align='center'>
<a href='#Installation'>Installation</a>
|
<a href='#Usage'>Usage</a>
</p><br>
## About
Optioner is a lightweight Argument Parser and easy to use. Full documentation [here](https://d33pster.github.io/optioner/)
## Installation
```console
$ pip install optioner
```
## Usage
###### initialization
[ [Full Documentation](https://d33pster.github.io/optioner/) ]
```console
>>> from optioner import options
>>> help(options)
Help on class options in module optioner:
class options(builtins.object)
| options(shortargs: list, longargs: list, gotargs: list)
|
| Methods defined here:
|
| __init__(self, shortargs: list, longargs: list, gotargs: list, compulsory_short_args:list =[], compulsory_long_args:list =[], ignore: list[str] [], ifthisthennotthat:list[list[str]] = [[],[]])
| init function: This runs everytime the class is called.
|
| Args:
| shortargs (list): example: ['h', 'l', 'i', ...]
| longargs (list): example: ['help', 'lock', 'init', ...]
| gotargs (list): sys.argv[1:]
| compulsory_short_args (list | optional): optional compulsory arguments
| compulsory_long_args (list | optional): corresponding optional compulsory arguments
| ignore (list[str] | optional): if these args are found, compulsion args will be overridden. (suitable if you have compulsory args and you also need --help or --version args)
| ifthisthennotthat (list[list[str]] | optional): if you have a condition where if a specific argument is provided, then some other argument cannot be provided.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables (if defined)
```
###### use method
after creating class object, call _argparse() method
help:
```console
>>> help(options._argparse)
Help on function _argparse in module optioner:
_argparse(self)
_argparse: checks all the arguments and stores error if any
Return:
actualargs (list): all valid args found.
argcheck (boolean): Boolean (True: all good, False: Found undefined args)
argerror (str): error note (if all good, no error note)
falseargs (list): wrong args if any. (if None, empty list)
```
usage:
```console
# import module
>>> from optioner import options
>>> import sys
# define short args
>>> shortargs = ['a', 'b']
# define long args
>>> longargs = ['assign', 'bind']
# create option control
>>> optionCTRL = options(shortargs, longargs, sys.argv[1:])
# get values
>>> actualargs, argcheck, argerror, falseargs = optionCTRL._argparse()
```
## Extra features
Added a function to query argument value.
```console
>>> help(options._what_is)
Help on function _what_is_ in module optioner:
_what_is_(self, arg: str)
Returns the value of the argument that is passed.
Args:
arg (str): argument you need the value of
count (int | optional): no of values you are expecting. Default is one
Returns:
str | tuple | None_: returns value of argument or None
```
usage:
```console
>>> optionCTRL = options(shortargs, longargs, gotargs)
>>> args, check, error, falseargs = optionCTRL._argparse()
>>> optionCTRL._what_is_(args[0])
or
>>> optionCTRL._what_is_(args[1])
```
```python
# NOTE: if the user provided a longarg say --input, _what_is_ can be used with the corresponding shortarg, in this case it is -i, to find the value.
## For example:
optCTRL = options(shortargs, longargs, argv[1:])
args, check, error, falseargs = optCTRL._argparse()
# now it doesn't matter a longarg or a short arg is passed.
# calling _what_is_ with the shortarg or longarg will return the value.
if '-i' in args or '--input' in args:
print(optCTRL._what_is_('i')) # or print(optCTRL._what_is_('input'))
# so if the user provided --input, if we call _what_is('i'), we can get the value.
# or if the user provided -i, we can call _what_is_('input'), to get the value.
# NOTE: this is an ease of use feature, only available for v1.5.2 and above.
```
Raw data
{
"_id": null,
"home_page": null,
"name": "optioner",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": "Soumyo Deep Gupta <deep.main.ac@gmail.com>",
"keywords": "d33pster, optioner, argument-parser, argument, parser, argparse",
"author": null,
"author_email": "Soumyo Deep Gupta <deep.main.ac@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/26/05/c1cb23cce2b24f065a2d90e7a33ecc9d5ba8b90d57123de7b964aff2d70b/optioner-1.5.2.tar.gz",
"platform": null,
"description": "# optioner\n[![Continuous Deployment](https://github.com/d33pster/optioner/actions/workflows/cont-dep.yml/badge.svg)](https://github.com/d33pster/optioner/actions/workflows/cont-dep.yml)\n[![Feature Tests](https://github.com/d33pster/optioner/actions/workflows/pytest.yml/badge.svg)](https://github.com/d33pster/optioner/actions/workflows/pytest.yml)\n[![Build status](https://ci.appveyor.com/api/projects/status/qoaeiypaxnonrosv?svg=true)](https://ci.appveyor.com/project/d33pster/optioner)\n[![codecov](https://codecov.io/gh/d33pster/optioner/graph/badge.svg?token=NE6E28GWCK)](https://codecov.io/gh/d33pster/optioner)\n![PyPI - Version](https://img.shields.io/pypi/v/optioner)\n![Python Version from PEP 621 TOML](https://img.shields.io/python/required-version-toml?tomlFilePath=https%3A%2F%2Fraw.githubusercontent.com%2Fd33pster%2Foptioner%2Fmain%2Fpyproject.toml)\n![PyPI - Wheel](https://img.shields.io/pypi/wheel/optioner)\n![Dependents (via libraries.io)](https://img.shields.io/librariesio/dependents/pypi/Optioner)\n![GitHub License](https://img.shields.io/github/license/d33pster/optioner)\n![GitHub last commit](https://img.shields.io/github/last-commit/d33pster/optioner)\n\n\n<br>\n\n<p align='center'>\n <a href='#Installation'>Installation</a>\n | \n <a href='#Usage'>Usage</a>\n</p><br>\n\n## About\nOptioner is a lightweight Argument Parser and easy to use. Full documentation [here](https://d33pster.github.io/optioner/)\n\n## Installation\n```console\n$ pip install optioner\n```\n\n## Usage\n\n###### initialization\n\n[ [Full Documentation](https://d33pster.github.io/optioner/) ]\n\n```console\n>>> from optioner import options\n>>> help(options)\n\nHelp on class options in module optioner:\n\nclass options(builtins.object)\n | options(shortargs: list, longargs: list, gotargs: list)\n |\n | Methods defined here:\n |\n | __init__(self, shortargs: list, longargs: list, gotargs: list, compulsory_short_args:list =[], compulsory_long_args:list =[], ignore: list[str] [], ifthisthennotthat:list[list[str]] = [[],[]])\n | init function: This runs everytime the class is called.\n |\n | Args:\n | shortargs (list): example: ['h', 'l', 'i', ...]\n | longargs (list): example: ['help', 'lock', 'init', ...]\n | gotargs (list): sys.argv[1:]\n | compulsory_short_args (list | optional): optional compulsory arguments\n | compulsory_long_args (list | optional): corresponding optional compulsory arguments\n | ignore (list[str] | optional): if these args are found, compulsion args will be overridden. (suitable if you have compulsory args and you also need --help or --version args)\n | ifthisthennotthat (list[list[str]] | optional): if you have a condition where if a specific argument is provided, then some other argument cannot be provided.\n |\n | ----------------------------------------------------------------------\n | Data descriptors defined here:\n |\n | __dict__\n | dictionary for instance variables (if defined)\n```\n###### use method\n\nafter creating class object, call _argparse() method\n\nhelp:\n```console\n>>> help(options._argparse)\n\nHelp on function _argparse in module optioner:\n\n_argparse(self)\n _argparse: checks all the arguments and stores error if any\n\n Return:\n actualargs (list): all valid args found.\n argcheck (boolean): Boolean (True: all good, False: Found undefined args)\n argerror (str): error note (if all good, no error note)\n falseargs (list): wrong args if any. (if None, empty list)\n```\n\nusage:\n```console\n# import module\n>>> from optioner import options\n>>> import sys\n# define short args\n>>> shortargs = ['a', 'b']\n# define long args\n>>> longargs = ['assign', 'bind']\n# create option control\n>>> optionCTRL = options(shortargs, longargs, sys.argv[1:])\n# get values\n>>> actualargs, argcheck, argerror, falseargs = optionCTRL._argparse()\n```\n\n## Extra features\nAdded a function to query argument value.\n```console\n>>> help(options._what_is)\n\nHelp on function _what_is_ in module optioner:\n\n_what_is_(self, arg: str)\n Returns the value of the argument that is passed.\n\n Args:\n arg (str): argument you need the value of\n count (int | optional): no of values you are expecting. Default is one\n\n Returns:\n str | tuple | None_: returns value of argument or None\n```\n\nusage:\n```console\n>>> optionCTRL = options(shortargs, longargs, gotargs)\n>>> args, check, error, falseargs = optionCTRL._argparse()\n\n>>> optionCTRL._what_is_(args[0])\n\nor \n\n>>> optionCTRL._what_is_(args[1])\n```\n```python\n# NOTE: if the user provided a longarg say --input, _what_is_ can be used with the corresponding shortarg, in this case it is -i, to find the value.\n\n## For example:\noptCTRL = options(shortargs, longargs, argv[1:])\nargs, check, error, falseargs = optCTRL._argparse()\n\n# now it doesn't matter a longarg or a short arg is passed.\n# calling _what_is_ with the shortarg or longarg will return the value.\n\nif '-i' in args or '--input' in args:\n print(optCTRL._what_is_('i')) # or print(optCTRL._what_is_('input'))\n\n# so if the user provided --input, if we call _what_is('i'), we can get the value.\n# or if the user provided -i, we can call _what_is_('input'), to get the value.\n# NOTE: this is an ease of use feature, only available for v1.5.2 and above.\n```\n",
"bugtrack_url": null,
"license": "MIT License Copyright (c) 2024 Soumyo Deep Gupta Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
"summary": "Argument Parser",
"version": "1.5.2",
"project_urls": {
"Documentation": "https://d33pster.github.io/optioner/",
"GitHub": "https://github.com/d33pster/optioner",
"Issues": "https://github.com/d33pster/optioner/issues"
},
"split_keywords": [
"d33pster",
" optioner",
" argument-parser",
" argument",
" parser",
" argparse"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "054c7030ae1659115378882a9a747e27de59abfefedff9bf53a89ca194fdd112",
"md5": "dfd9011fc3e6e2580581b2b2a775781f",
"sha256": "bc692864772209b89247fb5b9daa21393ec2435e07497bf4bc09efbc7c832692"
},
"downloads": -1,
"filename": "optioner-1.5.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "dfd9011fc3e6e2580581b2b2a775781f",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 6829,
"upload_time": "2024-04-12T20:35:27",
"upload_time_iso_8601": "2024-04-12T20:35:27.326501Z",
"url": "https://files.pythonhosted.org/packages/05/4c/7030ae1659115378882a9a747e27de59abfefedff9bf53a89ca194fdd112/optioner-1.5.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "2605c1cb23cce2b24f065a2d90e7a33ecc9d5ba8b90d57123de7b964aff2d70b",
"md5": "985433fa462f1cd61db4ec932391963b",
"sha256": "4b3e39ce3bbe505a395ee7798e0bf07ea1af6ce7d3440f92752f8e30c98f8158"
},
"downloads": -1,
"filename": "optioner-1.5.2.tar.gz",
"has_sig": false,
"md5_digest": "985433fa462f1cd61db4ec932391963b",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 6254,
"upload_time": "2024-04-12T20:35:29",
"upload_time_iso_8601": "2024-04-12T20:35:29.011638Z",
"url": "https://files.pythonhosted.org/packages/26/05/c1cb23cce2b24f065a2d90e7a33ecc9d5ba8b90d57123de7b964aff2d70b/optioner-1.5.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-04-12 20:35:29",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "d33pster",
"github_project": "optioner",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "pytest",
"specs": []
}
],
"lcname": "optioner"
}