ahk-json


Nameahk-json JSON
Version 0.1.0rc2 PyPI version JSON
download
home_pagehttps://github.com/spyoungtech/ahk-json
SummaryAuto-Hotkey-JSON for Python
upload_time2023-09-24 22:34:53
maintainer
docs_urlNone
authorSpencer Young
requires_python>=3.8.0
license
keywords ahk autohotkey jxon json python
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # ahk-json

This is an extension package intended to be used with the Python [ahk](https://github.com/spyoungtech/ahk) package.

It provides interfaces from [cocobelgica/AutoHotkey-JSON](https://github.com/cocobelgica/AutoHotkey-JSON) for
working with JSON in AutoHotkey. The extensions in this package do not provide any additional methods,
but simply provide a convenient way to include `Jxon.ahk` and/or `JSON.ahk` into other extensions.

This package provides two extensions: `JXON` and `JSON`. It also registers a JSON message type (`ahk_json.message.JsonResponseMessage`)

## Installation

Install this extension using `pip`

```python
pip install ahk-json
```

# Usage

Typically, you use this as a dependency when building your own extensions.

In the following example, a simple extension (`my_extension`) is created. It implements an AHK function `MyTestFunction`
-- the registered to the extension using the Python function `my_test_function`.
```python
from ahk.extensions import Extension
from ahk import AHK

from ahk_json import JXON  # importing is necessary for ``extensions='auto'`` to work, even if this is not used

ext_script = '''\
MyTestFunction(ByRef command) {
    arg := command[2]
    obj := Object("test", arg)
    res := Jxon_Dump(obj) ; this is available thanks to the extension
    return FormatResponse("ahk_json.message.JsonResponseMessage", res)
}
'''

my_extension = Extension(script_text=ext_script)

@my_extension.register
def my_test_function(ahk: AHK, arg: str):
    return ahk.function_call('MyTestFunction', [arg])


def main():
    ahk = AHK(extensions='auto')  # automatically use all imported/created extensions
    # or use the extensions explicitly:
    # ahk = AHK(extensions=[JXON, my_extension])

    # now ``.my_test_function`` is a method on the `ahk` instance:
    assert ahk.my_test_function('foo') == {'test': 'foo'}
```


# License

This work is licensed under the MIT license.

This package includes substantial portions of the [original AutoHotkey-JSON](https://github.com/cocobelgica/AutoHotkey-JSON).
The code included from AutoHotkey-JSON is owned and copyrighted by its original author(s) and is used/redistributed
under the terms of the [WTFPL](http://www.wtfpl.net).

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/spyoungtech/ahk-json",
    "name": "ahk-json",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8.0",
    "maintainer_email": "",
    "keywords": "ahk,autohotkey,jxon,json,python",
    "author": "Spencer Young",
    "author_email": "spencer.young@spyoung.com",
    "download_url": "https://files.pythonhosted.org/packages/eb/1d/6729ab0c4fbdb23f61f30e2cc0330bc36625be0264a10d094f1eea0fef66/ahk-json-0.1.0rc2.tar.gz",
    "platform": null,
    "description": "# ahk-json\n\nThis is an extension package intended to be used with the Python [ahk](https://github.com/spyoungtech/ahk) package.\n\nIt provides interfaces from [cocobelgica/AutoHotkey-JSON](https://github.com/cocobelgica/AutoHotkey-JSON) for\nworking with JSON in AutoHotkey. The extensions in this package do not provide any additional methods,\nbut simply provide a convenient way to include `Jxon.ahk` and/or `JSON.ahk` into other extensions.\n\nThis package provides two extensions: `JXON` and `JSON`. It also registers a JSON message type (`ahk_json.message.JsonResponseMessage`)\n\n## Installation\n\nInstall this extension using `pip`\n\n```python\npip install ahk-json\n```\n\n# Usage\n\nTypically, you use this as a dependency when building your own extensions.\n\nIn the following example, a simple extension (`my_extension`) is created. It implements an AHK function `MyTestFunction`\n-- the registered to the extension using the Python function `my_test_function`.\n```python\nfrom ahk.extensions import Extension\nfrom ahk import AHK\n\nfrom ahk_json import JXON  # importing is necessary for ``extensions='auto'`` to work, even if this is not used\n\next_script = '''\\\nMyTestFunction(ByRef command) {\n    arg := command[2]\n    obj := Object(\"test\", arg)\n    res := Jxon_Dump(obj) ; this is available thanks to the extension\n    return FormatResponse(\"ahk_json.message.JsonResponseMessage\", res)\n}\n'''\n\nmy_extension = Extension(script_text=ext_script)\n\n@my_extension.register\ndef my_test_function(ahk: AHK, arg: str):\n    return ahk.function_call('MyTestFunction', [arg])\n\n\ndef main():\n    ahk = AHK(extensions='auto')  # automatically use all imported/created extensions\n    # or use the extensions explicitly:\n    # ahk = AHK(extensions=[JXON, my_extension])\n\n    # now ``.my_test_function`` is a method on the `ahk` instance:\n    assert ahk.my_test_function('foo') == {'test': 'foo'}\n```\n\n\n# License\n\nThis work is licensed under the MIT license.\n\nThis package includes substantial portions of the [original AutoHotkey-JSON](https://github.com/cocobelgica/AutoHotkey-JSON).\nThe code included from AutoHotkey-JSON is owned and copyrighted by its original author(s) and is used/redistributed\nunder the terms of the [WTFPL](http://www.wtfpl.net).\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Auto-Hotkey-JSON for Python",
    "version": "0.1.0rc2",
    "project_urls": {
        "Homepage": "https://github.com/spyoungtech/ahk-json"
    },
    "split_keywords": [
        "ahk",
        "autohotkey",
        "jxon",
        "json",
        "python"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0882c636789d1e970d1ab682968e4f108901fd11014959b076e8c81460e66838",
                "md5": "900ca1ebd3f9f1881dda5394b5688cfc",
                "sha256": "64fcf02a98623df3322ed617bb78652d5aa427cff1180674ab7c792a7e688ff9"
            },
            "downloads": -1,
            "filename": "ahk_json-0.1.0rc2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "900ca1ebd3f9f1881dda5394b5688cfc",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8.0",
            "size": 11500,
            "upload_time": "2023-09-24T22:34:52",
            "upload_time_iso_8601": "2023-09-24T22:34:52.280112Z",
            "url": "https://files.pythonhosted.org/packages/08/82/c636789d1e970d1ab682968e4f108901fd11014959b076e8c81460e66838/ahk_json-0.1.0rc2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "eb1d6729ab0c4fbdb23f61f30e2cc0330bc36625be0264a10d094f1eea0fef66",
                "md5": "32bc81284257b14f81960b892ded8aed",
                "sha256": "97748224e75d4daecef9b6fa661f82d1fe1b0bdaf1e53efde2c41f2f8aa46469"
            },
            "downloads": -1,
            "filename": "ahk-json-0.1.0rc2.tar.gz",
            "has_sig": false,
            "md5_digest": "32bc81284257b14f81960b892ded8aed",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8.0",
            "size": 10990,
            "upload_time": "2023-09-24T22:34:53",
            "upload_time_iso_8601": "2023-09-24T22:34:53.871703Z",
            "url": "https://files.pythonhosted.org/packages/eb/1d/6729ab0c4fbdb23f61f30e2cc0330bc36625be0264a10d094f1eea0fef66/ahk-json-0.1.0rc2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-09-24 22:34:53",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "spyoungtech",
    "github_project": "ahk-json",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "ahk-json"
}
        
Elapsed time: 0.12774s