easy-events


Nameeasy-events JSON
Version 3.1.1 PyPI version JSON
download
home_pagehttps://github.com/ThePhoenix78/easy-events
SummaryAn universal wrapper (and useful tool) to make event / commands in python
upload_time2023-11-20 17:48:21
maintainer
docs_urlNone
authorThePhoenix78
requires_python
licenseMIT
keywords wrapper event commands command
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # easy-events

**A library that help you to manage events**

## Getting started

1. [**Installation**](#installation)
2. [**Usages**](#usages)
3. [**Code example**](#code-example)
4. [**Documentation**](#documentation)

## Installation

`pip install easy-events`

GitHub : [Github](https://github.com/ThePhoenix78/Commands)


## Usages

text

## Code example

```py
from easy_events import EasyEvents

# create an event or use it in a class
client = EasyEvents()


# create another event (can be sync or async)
# you can put as much parameters as you want
@client.add_event(aliases="test1")
def test(arg1, arg2, *, arg3):
	# data is the default parameter, it contain some basic informations that you can format as you want
	print(arg1, arg2, arg3)


# trigger the event
client.trigger(data=test1, parameters="arg1 arg2 arg3 arg4")
client.trigger("test1", "arg1 arg2 arg3 arg4")
client.trigger("test1", ["arg1", "arg2", "arg3", "arg4"])
client.trigger("test1", {"arg1": "arg1", "arg2": "arg2", "arg3": ["arg3", "arg4"]})

# dict way
client.trigger({"event": "test1", "parameters": {"arg1": "arg1", "arg2": "arg2", "arg3": ["arg3", "arg4"]}})

# dict way v2
client.trigger({"event": "test", "parameters": ["arg1", "arg2", "arg3", "arg4"]})

# dict way v3
client.trigger({"event": "test1", "parameters": "arg1 arg2 arg3 arg4"})

# list way
client.trigger(["test", "arg1", "arg2", "arg3", "arg4"])

# str way
client.trigger("test arg1 arg2 arg3 arg4")

# the result will be (for all cases):
# arg1 = arg1
# arg2 = arg2
# arg3 = [arg3, arg4]

```

### This library also support type assignation

```py
from easy_events import EasyEvents

client = EasyEvents()


@client.add_event()
def sum(X: int, Y: int):
	return X+Y


client.trigger("sum 5 10")
client.trigger(["sum", "5", 10])
# the result will be 15
```


### Context support


```py
from easy_events import EasyEvents


class CTX:
	def __init__(self, data: int = 0):
		self.data = data


client = EasyEvents(default_context=CTX)
# client = EasyEvents(default_context=CTX(0)) works as well

@client.add_event()
def context(ctx):
	print("ctx.data = ", ctx.data)


client.trigger("context", context=CTX(1))
client.trigger("context")

# this will print :
# "ctx.data = 1"
# "ctx.data = 0"
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/ThePhoenix78/easy-events",
    "name": "easy-events",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "wrapper,event,commands,command",
    "author": "ThePhoenix78",
    "author_email": "thephoenix788@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/45/a9/a40d8ac9805f9f933465583929b010f1dade3d45b3e66a3c33b17ab9cf18/easy-events-3.1.1.tar.gz",
    "platform": null,
    "description": "# easy-events\r\n\r\n**A library that help you to manage events**\r\n\r\n## Getting started\r\n\r\n1. [**Installation**](#installation)\r\n2. [**Usages**](#usages)\r\n3. [**Code example**](#code-example)\r\n4. [**Documentation**](#documentation)\r\n\r\n## Installation\r\n\r\n`pip install easy-events`\r\n\r\nGitHub : [Github](https://github.com/ThePhoenix78/Commands)\r\n\r\n\r\n## Usages\r\n\r\ntext\r\n\r\n## Code example\r\n\r\n```py\r\nfrom easy_events import EasyEvents\r\n\r\n# create an event or use it in a class\r\nclient = EasyEvents()\r\n\r\n\r\n# create another event (can be sync or async)\r\n# you can put as much parameters as you want\r\n@client.add_event(aliases=\"test1\")\r\ndef test(arg1, arg2, *, arg3):\r\n\t# data is the default parameter, it contain some basic informations that you can format as you want\r\n\tprint(arg1, arg2, arg3)\r\n\r\n\r\n# trigger the event\r\nclient.trigger(data=test1, parameters=\"arg1 arg2 arg3 arg4\")\r\nclient.trigger(\"test1\", \"arg1 arg2 arg3 arg4\")\r\nclient.trigger(\"test1\", [\"arg1\", \"arg2\", \"arg3\", \"arg4\"])\r\nclient.trigger(\"test1\", {\"arg1\": \"arg1\", \"arg2\": \"arg2\", \"arg3\": [\"arg3\", \"arg4\"]})\r\n\r\n# dict way\r\nclient.trigger({\"event\": \"test1\", \"parameters\": {\"arg1\": \"arg1\", \"arg2\": \"arg2\", \"arg3\": [\"arg3\", \"arg4\"]}})\r\n\r\n# dict way v2\r\nclient.trigger({\"event\": \"test\", \"parameters\": [\"arg1\", \"arg2\", \"arg3\", \"arg4\"]})\r\n\r\n# dict way v3\r\nclient.trigger({\"event\": \"test1\", \"parameters\": \"arg1 arg2 arg3 arg4\"})\r\n\r\n# list way\r\nclient.trigger([\"test\", \"arg1\", \"arg2\", \"arg3\", \"arg4\"])\r\n\r\n# str way\r\nclient.trigger(\"test arg1 arg2 arg3 arg4\")\r\n\r\n# the result will be (for all cases):\r\n# arg1 = arg1\r\n# arg2 = arg2\r\n# arg3 = [arg3, arg4]\r\n\r\n```\r\n\r\n### This library also support type assignation\r\n\r\n```py\r\nfrom easy_events import EasyEvents\r\n\r\nclient = EasyEvents()\r\n\r\n\r\n@client.add_event()\r\ndef sum(X: int, Y: int):\r\n\treturn X+Y\r\n\r\n\r\nclient.trigger(\"sum 5 10\")\r\nclient.trigger([\"sum\", \"5\", 10])\r\n# the result will be 15\r\n```\r\n\r\n\r\n### Context support\r\n\r\n\r\n```py\r\nfrom easy_events import EasyEvents\r\n\r\n\r\nclass CTX:\r\n\tdef __init__(self, data: int = 0):\r\n\t\tself.data = data\r\n\r\n\r\nclient = EasyEvents(default_context=CTX)\r\n# client = EasyEvents(default_context=CTX(0)) works as well\r\n\r\n@client.add_event()\r\ndef context(ctx):\r\n\tprint(\"ctx.data = \", ctx.data)\r\n\r\n\r\nclient.trigger(\"context\", context=CTX(1))\r\nclient.trigger(\"context\")\r\n\r\n# this will print :\r\n# \"ctx.data = 1\"\r\n# \"ctx.data = 0\"\r\n```\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "An universal wrapper (and useful tool) to make event / commands in python",
    "version": "3.1.1",
    "project_urls": {
        "Download": "https://github.com/ThePhoenix78/easy-events/tarball/master",
        "Homepage": "https://github.com/ThePhoenix78/easy-events"
    },
    "split_keywords": [
        "wrapper",
        "event",
        "commands",
        "command"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2bdd010f8f22623c007cdaeaec4329e8a7feab4a98ad0499684a8d729b15775b",
                "md5": "c64b787e1f5bee55e4d172bd9f5a908f",
                "sha256": "7af8e7f5bd1cfcd62571bcfc5e11a4e096eddbe8480a08e86eba40827cacbd41"
            },
            "downloads": -1,
            "filename": "easy_events-3.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c64b787e1f5bee55e4d172bd9f5a908f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 10987,
            "upload_time": "2023-11-20T17:48:19",
            "upload_time_iso_8601": "2023-11-20T17:48:19.760452Z",
            "url": "https://files.pythonhosted.org/packages/2b/dd/010f8f22623c007cdaeaec4329e8a7feab4a98ad0499684a8d729b15775b/easy_events-3.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "45a9a40d8ac9805f9f933465583929b010f1dade3d45b3e66a3c33b17ab9cf18",
                "md5": "12248184e72ba83cfe7447c7b61e17cd",
                "sha256": "74f216ae039a9773a3d2cee4dd7900521c45d82e2921ac87cd8362ffede4774e"
            },
            "downloads": -1,
            "filename": "easy-events-3.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "12248184e72ba83cfe7447c7b61e17cd",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 9221,
            "upload_time": "2023-11-20T17:48:21",
            "upload_time_iso_8601": "2023-11-20T17:48:21.480652Z",
            "url": "https://files.pythonhosted.org/packages/45/a9/a40d8ac9805f9f933465583929b010f1dade3d45b3e66a3c33b17ab9cf18/easy-events-3.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-11-20 17:48:21",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ThePhoenix78",
    "github_project": "easy-events",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "easy-events"
}
        
Elapsed time: 0.28822s