ehorizon 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,67 @@
1
+ Metadata-Version: 2.4
2
+ Name: ehorizon
3
+ Version: 0.1.0
4
+ Summary: A python library that adds events to communicate through other files.
5
+ Author-email: Hero3806 <sussymanxdxd@gmail.com>
6
+ License: MIT
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: License :: OSI Approved :: MIT License
9
+ Classifier: Operating System :: OS Independent
10
+ Requires-Python: >=3.8
11
+ Description-Content-Type: text/markdown
12
+
13
+ # Event Horizon
14
+
15
+ A python library that adds events to communicate through other files.
16
+
17
+ ## Installation
18
+
19
+ ```bash
20
+ pip install event-horizon
21
+ ```
22
+
23
+ ## Example Code Snippet
24
+
25
+ - Events:
26
+
27
+ test.py:
28
+ ```py
29
+ from EventHorizon import Event
30
+ import callback
31
+
32
+ myEvent = Event("MyEvent")
33
+
34
+ myEvent.Fire("Hello World!")
35
+ ```
36
+
37
+ callback.py:
38
+ ```py
39
+ from EventHorizon import Event
40
+
41
+ @Event("MyEvent").OnEvent
42
+ def callback(message):
43
+ print(message)
44
+ ```
45
+
46
+ - Functions:
47
+
48
+ test.py:
49
+ ```py
50
+ from EventHorizon import Function
51
+ import function
52
+
53
+ myFunc = Function("MyFunc")
54
+
55
+ favourite_number = myFunc.run()
56
+
57
+ print(favourite_number)
58
+ ```
59
+
60
+ function.py:
61
+ ```py
62
+ from EventHorizon import Function
63
+
64
+ @Function("MyFunc").AttachFunction
65
+ def callback():
66
+ return 5
67
+ ```
@@ -0,0 +1,55 @@
1
+ # Event Horizon
2
+
3
+ A python library that adds events to communicate through other files.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pip install event-horizon
9
+ ```
10
+
11
+ ## Example Code Snippet
12
+
13
+ - Events:
14
+
15
+ test.py:
16
+ ```py
17
+ from EventHorizon import Event
18
+ import callback
19
+
20
+ myEvent = Event("MyEvent")
21
+
22
+ myEvent.Fire("Hello World!")
23
+ ```
24
+
25
+ callback.py:
26
+ ```py
27
+ from EventHorizon import Event
28
+
29
+ @Event("MyEvent").OnEvent
30
+ def callback(message):
31
+ print(message)
32
+ ```
33
+
34
+ - Functions:
35
+
36
+ test.py:
37
+ ```py
38
+ from EventHorizon import Function
39
+ import function
40
+
41
+ myFunc = Function("MyFunc")
42
+
43
+ favourite_number = myFunc.run()
44
+
45
+ print(favourite_number)
46
+ ```
47
+
48
+ function.py:
49
+ ```py
50
+ from EventHorizon import Function
51
+
52
+ @Function("MyFunc").AttachFunction
53
+ def callback():
54
+ return 5
55
+ ```
@@ -0,0 +1,25 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "ehorizon"
7
+ version = "0.1.0"
8
+ authors = [
9
+ { name="Hero3806", email="sussymanxdxd@gmail.com" }
10
+ ]
11
+ description = "A python library that adds events to communicate through other files."
12
+ readme = "README.md"
13
+ requires-python = ">=3.8"
14
+ license = { text = "MIT" }
15
+
16
+ dependencies = []
17
+
18
+ classifiers = [
19
+ "Programming Language :: Python :: 3",
20
+ "License :: OSI Approved :: MIT License",
21
+ "Operating System :: OS Independent",
22
+ ]
23
+
24
+ [tool.setuptools.packages.find]
25
+ where = ["src"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,4 @@
1
+ from .event import Event
2
+ from .func import Function
3
+
4
+ __version__ = "0.1.0"
@@ -0,0 +1,47 @@
1
+ from typing import Callable
2
+
3
+ class Event:
4
+ _events = {}
5
+
6
+ def __new__(cls, name):
7
+ if name in cls._events:
8
+ return cls._events[name]
9
+
10
+ instance = super().__new__(cls)
11
+ cls._events[name] = instance
12
+ return instance
13
+
14
+ def __init__(self, name):
15
+ if hasattr(self, "_initialized"):
16
+ return
17
+
18
+ self.name = name
19
+ self.callback = None
20
+ self._initialized = True
21
+
22
+ @classmethod
23
+ def delete_by_name(cls, name: str):
24
+ """Deletes the function by the given name."""
25
+ """@name Name of the function."""
26
+ cls._events.pop(name, None)
27
+
28
+ # Fires the event that has been binded from another file or the current file.
29
+ # Supports multiple arguments.
30
+ def Fire(self, *args, **kwargs):
31
+ """Fires the event that has been binded from another file or the current file."""
32
+ """Supports multiple arguments."""
33
+ if not self.callback:
34
+ raise Exception("There is no callback for this event, did you forget to add an 'OnEvent' callback?")
35
+
36
+ self.callback(*args, **kwargs)
37
+
38
+ # Register the callback for the event
39
+ def OnEvent(self, cb: Callable[..., None]):
40
+ """Register the callback for the event"""
41
+ self.callback = cb
42
+ return cb
43
+
44
+ def delete(self):
45
+ """Delete the current event entirely"""
46
+ """NOTE: Deleting this will make this instance completely unusable and will require creating a new instance."""
47
+ Event._events.pop(self.name, None)
@@ -0,0 +1,45 @@
1
+ from typing import Callable
2
+ from typing import Any
3
+
4
+ class Function:
5
+ _funcs = {}
6
+
7
+ def __new__(cls, name):
8
+ if name in cls._funcs:
9
+ return cls._funcs[name]
10
+
11
+ instance = super().__new__(cls)
12
+ cls._funcs[name] = instance
13
+ return instance
14
+
15
+ def __init__(self, name):
16
+ if hasattr(self, "_initialized"):
17
+ return
18
+
19
+ self.name = name
20
+ self.callback = None
21
+ self._initialized = True
22
+
23
+ @classmethod
24
+ def delete_by_name(cls, name: str):
25
+ """Deletes the function by the given name."""
26
+ """@name Name of the function."""
27
+ cls._funcs.pop(name, None)
28
+
29
+ def run(self, *args, **kwargs):
30
+ """Fires the function that has been binded and returns the value from it."""
31
+ """Supports multiple arguments."""
32
+ if not self.callback:
33
+ raise Exception("There is no callback for this function, did you forget to add an 'AttachFunction' callback?")
34
+
35
+ return self.callback(*args, **kwargs)
36
+
37
+ def AttachFunction(self, cb: Callable[..., Any]):
38
+ """Register the callback for the function"""
39
+ self.callback = cb
40
+ return cb
41
+
42
+ def delete(self):
43
+ """Delete the current function entirely"""
44
+ """NOTE: Deleting this will make this instance completely unusable and will require creating a new instance."""
45
+ Function._funcs.pop(self.name, None)
@@ -0,0 +1,67 @@
1
+ Metadata-Version: 2.4
2
+ Name: ehorizon
3
+ Version: 0.1.0
4
+ Summary: A python library that adds events to communicate through other files.
5
+ Author-email: Hero3806 <sussymanxdxd@gmail.com>
6
+ License: MIT
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: License :: OSI Approved :: MIT License
9
+ Classifier: Operating System :: OS Independent
10
+ Requires-Python: >=3.8
11
+ Description-Content-Type: text/markdown
12
+
13
+ # Event Horizon
14
+
15
+ A python library that adds events to communicate through other files.
16
+
17
+ ## Installation
18
+
19
+ ```bash
20
+ pip install event-horizon
21
+ ```
22
+
23
+ ## Example Code Snippet
24
+
25
+ - Events:
26
+
27
+ test.py:
28
+ ```py
29
+ from EventHorizon import Event
30
+ import callback
31
+
32
+ myEvent = Event("MyEvent")
33
+
34
+ myEvent.Fire("Hello World!")
35
+ ```
36
+
37
+ callback.py:
38
+ ```py
39
+ from EventHorizon import Event
40
+
41
+ @Event("MyEvent").OnEvent
42
+ def callback(message):
43
+ print(message)
44
+ ```
45
+
46
+ - Functions:
47
+
48
+ test.py:
49
+ ```py
50
+ from EventHorizon import Function
51
+ import function
52
+
53
+ myFunc = Function("MyFunc")
54
+
55
+ favourite_number = myFunc.run()
56
+
57
+ print(favourite_number)
58
+ ```
59
+
60
+ function.py:
61
+ ```py
62
+ from EventHorizon import Function
63
+
64
+ @Function("MyFunc").AttachFunction
65
+ def callback():
66
+ return 5
67
+ ```
@@ -0,0 +1,9 @@
1
+ README.md
2
+ pyproject.toml
3
+ src/EventHorizon/__init__.py
4
+ src/EventHorizon/event.py
5
+ src/EventHorizon/func.py
6
+ src/ehorizon.egg-info/PKG-INFO
7
+ src/ehorizon.egg-info/SOURCES.txt
8
+ src/ehorizon.egg-info/dependency_links.txt
9
+ src/ehorizon.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ EventHorizon