optfunc2


Nameoptfunc2 JSON
Version 0.1.2 PyPI version JSON
download
home_pageNone
SummaryGenerate options from function.
upload_time2024-12-16 07:28:05
maintainerNone
docs_urlNone
authorNone
requires_python>=3.7
licenseCopyright (c) 2016 The Python Packaging Authority (PyPA) 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 call function option
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Call function directly in cmd line

### Features
1. Allow user call functions directly in command line.
2. Generate help tips automatically.
3. Add default called functions if not function was specific.

### Notice
1. It's better to add argument type for each autocall functions.
2. Function with @optfunc_default has @optfunc implicitly.
3. Arguments of function with @optfunc_default should be optional or no argument.
4. Not support two type of variadic arguments.

### ChangeLog
#### 0.1.2 (2023-05-06)
1. Add support for default called functions.
2. Fix README.md.
3. Add ChangeLog in README.md.

### Code example
``` python
from optfunc2 import *

@optfunc
def arg_test_positional_only(pos_only0, pos_only1: int, pos_only2 = 5, pos_only3: int = 6):
    """summary for the function

    Args:
        pos_only0 (_type_): This is the first positional-only argument.
        pos_only1 (int): This is the second positional-only argument.
        pos_only2 (int, optional): This is the third positional-only argument. Defaults to 5.
        pos_only3 (int, optional): This is the fourth positional-only argument. Defaults to 6.
    """
    " Argument test for positional-only arguments. "
    print(f'pos_only0: {pos_only0}, pos_only1: {pos_only1}, pos_only2: {pos_only2}, pos_only3: {pos_only3}')
    pass

@optfunc
def arg_test_positional_or_keyword(pos_or_kw, pos_or_kw1: int, pos_or_kw2 = 3, pos_or_kw3: int = 4):
    " Argument test for positional-or-keyword arguments. "
    print(f'pos_or_kw: {pos_or_kw}, pos_or_kw1: {pos_or_kw1}, pos_or_kw2: {pos_or_kw2}, pos_or_kw3: {pos_or_kw3}')
    pass

@optfunc
def arg_test_kw_only(*, kw_only0, kw_only1: int, kw_only2 = 9, kw_only3: int = 10):
    " Argument test for keyword-only arguments. "
    print(f'kw_only0: {kw_only0}, kw_only1: {kw_only1}, kw_only2: {kw_only2}, kw_only3: {kw_only3}')
    pass

if __name__ == '__main__':
    optfunc_start(globals=globals(), has_abbrev=False, header_doc='This is a test file for the module "autocall".')
```
### Run the code
``` bash
~/:$ python3 test.py -h
Usage: test.py [command] [<args>|--help]

This is a test file for the module "autocall".

commands:
    arg_test_positional_only           summary for the function
    arg_test_positional_or_keyword     Argument test for positional-or-keyword arguments.
    arg_test_kw_only                   Argument test for keyword-only arguments.

~/:$ python3 test.py arg_test_positional_only -h
Usage: test.py arg_test_positional_only [OPTIONS]

summary for the function


Arguments:
+-------------+------+---------+-------------------------------------------------------------+
|     Opt     | Type | Default |                             Desc                            |
+-------------+------+---------+-------------------------------------------------------------+
| --pos_only0 | any  |         |         This is the first positional-only argument.         |
| --pos_only1 | int  |         |         This is the second positional-only argument.        |
| --pos_only2 | any  |    5    |  This is the third positional-only argument. Defaults to 5. |
| --pos_only3 | int  |    6    | This is the fourth positional-only argument. Defaults to 6. |
+-------------+------+---------+-------------------------------------------------------------+
~/:$ python3 test.py arg_test_positional_only --pos_only0 "good day" --pos_only1 2
pos_only0: good day, pos_only1: 2, pos_only2: 5, pos_only3: 6
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "optfunc2",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "bajeer <z_bajer@yeah.net>",
    "keywords": "call, function, option",
    "author": null,
    "author_email": "bajeer <z_bajer@yeah.net>",
    "download_url": "https://files.pythonhosted.org/packages/f0/6d/cacd09c0fa82dde370e2721cb1f26c83d832a62d0524c3a28f716f9b5514/optfunc2-0.1.2.tar.gz",
    "platform": null,
    "description": "# Call function directly in cmd line\n\n### Features\n1. Allow user call functions directly in command line.\n2. Generate help tips automatically.\n3. Add default called functions if not function was specific.\n\n### Notice\n1. It's better to add argument type for each autocall functions.\n2. Function with @optfunc_default has @optfunc implicitly.\n3. Arguments of function with @optfunc_default should be optional or no argument.\n4. Not support two type of variadic arguments.\n\n### ChangeLog\n#### 0.1.2 (2023-05-06)\n1. Add support for default called functions.\n2. Fix README.md.\n3. Add ChangeLog in README.md.\n\n### Code example\n``` python\nfrom optfunc2 import *\n\n@optfunc\ndef arg_test_positional_only(pos_only0, pos_only1: int, pos_only2 = 5, pos_only3: int = 6):\n    \"\"\"summary for the function\n\n    Args:\n        pos_only0 (_type_): This is the first positional-only argument.\n        pos_only1 (int): This is the second positional-only argument.\n        pos_only2 (int, optional): This is the third positional-only argument. Defaults to 5.\n        pos_only3 (int, optional): This is the fourth positional-only argument. Defaults to 6.\n    \"\"\"\n    \" Argument test for positional-only arguments. \"\n    print(f'pos_only0: {pos_only0}, pos_only1: {pos_only1}, pos_only2: {pos_only2}, pos_only3: {pos_only3}')\n    pass\n\n@optfunc\ndef arg_test_positional_or_keyword(pos_or_kw, pos_or_kw1: int, pos_or_kw2 = 3, pos_or_kw3: int = 4):\n    \" Argument test for positional-or-keyword arguments. \"\n    print(f'pos_or_kw: {pos_or_kw}, pos_or_kw1: {pos_or_kw1}, pos_or_kw2: {pos_or_kw2}, pos_or_kw3: {pos_or_kw3}')\n    pass\n\n@optfunc\ndef arg_test_kw_only(*, kw_only0, kw_only1: int, kw_only2 = 9, kw_only3: int = 10):\n    \" Argument test for keyword-only arguments. \"\n    print(f'kw_only0: {kw_only0}, kw_only1: {kw_only1}, kw_only2: {kw_only2}, kw_only3: {kw_only3}')\n    pass\n\nif __name__ == '__main__':\n    optfunc_start(globals=globals(), has_abbrev=False, header_doc='This is a test file for the module \"autocall\".')\n```\n### Run the code\n``` bash\n~/:$ python3 test.py -h\nUsage: test.py [command] [<args>|--help]\n\nThis is a test file for the module \"autocall\".\n\ncommands:\n    arg_test_positional_only           summary for the function\n    arg_test_positional_or_keyword     Argument test for positional-or-keyword arguments.\n    arg_test_kw_only                   Argument test for keyword-only arguments.\n\n~/:$ python3 test.py arg_test_positional_only -h\nUsage: test.py arg_test_positional_only [OPTIONS]\n\nsummary for the function\n\n\nArguments:\n+-------------+------+---------+-------------------------------------------------------------+\n|     Opt     | Type | Default |                             Desc                            |\n+-------------+------+---------+-------------------------------------------------------------+\n| --pos_only0 | any  |         |         This is the first positional-only argument.         |\n| --pos_only1 | int  |         |         This is the second positional-only argument.        |\n| --pos_only2 | any  |    5    |  This is the third positional-only argument. Defaults to 5. |\n| --pos_only3 | int  |    6    | This is the fourth positional-only argument. Defaults to 6. |\n+-------------+------+---------+-------------------------------------------------------------+\n~/:$ python3 test.py arg_test_positional_only --pos_only0 \"good day\" --pos_only1 2\npos_only0: good day, pos_only1: 2, pos_only2: 5, pos_only3: 6\n```\n",
    "bugtrack_url": null,
    "license": "Copyright (c) 2016 The Python Packaging Authority (PyPA)  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": "Generate options from function.",
    "version": "0.1.2",
    "project_urls": {
        "Bug Reports": "https://gitee.com/z-bajer/autocall/issues",
        "Homepage": "https://gitee.com/z-bajer/autocall",
        "Source": "https://gitee.com/z-bajer/autocall"
    },
    "split_keywords": [
        "call",
        " function",
        " option"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f066bb73d22104ed8046d0b4bef1d68df3628edcd4e1c442bb2e0376677dd1ef",
                "md5": "d0d4048bf0c9282facfc87c1971dbee2",
                "sha256": "764d81e523c4fd88183f355abb5004fcfe40b75e531c07d913ee4edef270d11b"
            },
            "downloads": -1,
            "filename": "optfunc2-0.1.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d0d4048bf0c9282facfc87c1971dbee2",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 7859,
            "upload_time": "2024-12-16T07:28:04",
            "upload_time_iso_8601": "2024-12-16T07:28:04.379204Z",
            "url": "https://files.pythonhosted.org/packages/f0/66/bb73d22104ed8046d0b4bef1d68df3628edcd4e1c442bb2e0376677dd1ef/optfunc2-0.1.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f06dcacd09c0fa82dde370e2721cb1f26c83d832a62d0524c3a28f716f9b5514",
                "md5": "67f103219ca8504bd7d564d84aaa5472",
                "sha256": "3e39e870087f878a89b0266f8ba1d964a92f91a6c06aca28386bfba837c31b45"
            },
            "downloads": -1,
            "filename": "optfunc2-0.1.2.tar.gz",
            "has_sig": false,
            "md5_digest": "67f103219ca8504bd7d564d84aaa5472",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 10279,
            "upload_time": "2024-12-16T07:28:05",
            "upload_time_iso_8601": "2024-12-16T07:28:05.708683Z",
            "url": "https://files.pythonhosted.org/packages/f0/6d/cacd09c0fa82dde370e2721cb1f26c83d832a62d0524c3a28f716f9b5514/optfunc2-0.1.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-16 07:28:05",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "optfunc2"
}
        
Elapsed time: 0.44920s