Name | SnakeNest JSON |
Version |
0.2.1
JSON |
| download |
home_page | None |
Summary | Snake Nest |
upload_time | 2024-04-07 06:29:36 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.9 |
license | None |
keywords |
codelithic
injection
spring
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# SnakeNest
nest.yaml
```yaml
application:
name: test
spesa:
- casa
- sale
- olio
snake:
test:
enable: pollo
```
Example 1
```python
from snakenest import *
from abc import ABC, abstractmethod
class WorkflowManager(ABC):
@abstractmethod
def test(self):
pass
@Snake(condition={'key': 'snake.test.enable', 'value': 'salame'})
class Test1(WorkflowManager):
def __init__(self):
super().__init__()
def test(self):
print("Test1")
@Snake(condition={'key': 'snake.test.enable', 'value': 'pollo'})
class Test2(WorkflowManager):
def __init__(self):
super().__init__()
def test(self):
print("Test2")
class Check:
@Poisoned()
def __init__(self, wf: WorkflowManager):
wf.test()
def print_hi(name):
Check()
if __name__ == '__main__':
Nest.initialize()
print_hi('Clint')
```
Example 2
```python
from snakenest import *
@Snake(args={"val1": "10", "val2": "22"})
class Config:
def __init__(self, val1, val2):
self.val1 = val1
self.val2 = val2
def get_val1(self):
return self.val1
def get_val2(self):
return self.val2
@Snake()
class MyCondition:
def __init__(self):
pass
@Snake()
class Test:
@Poisoned()
def __init__(self, config: Config):
self.__config = config
print(f'Test: {self.__config.__dict__}')
def hello(self, name):
return f"Test: Hello {name}"
def getName(self):
return "test_name"
@Snake(name='testName', args={"q": "10", "b": "${application.spesa:casa}"})
class Pollo:
def __init__(self, q, b):
self.q, self.b = q, b
def hello(self, name):
return f"Test_named: Hello {name}"
def getName(self):
return f'Pollo -> TestNamed: {self.q} - {self.b}'
class Test2:
@Poisoned()
def __init__(self, config: Config):
self.__config = config
print(f'Test2: {self.__config.__dict__}')
@Poisoned()
def getTestName(self, panico, name: Test):
return name.hello(panico)
@Poisoned(name='testName')
def getTestName2(self, name): # <-- tipo non definito ma injected
return name.getName()
def print_hi(name):
t2 = Test2()
print(f'Hi, {name}, {t2.getTestName("sale")} {t2.getTestName2()} ')
if __name__ == '__main__':
Nest.initialize()
print_hi('PyCharm')
# SnakeNest.clear()
```
SnakeBus message
```python
class MySubscriber(SnakeNotificationSubscriber):
def handle_event(self, event_type, data=None):
print(f'Received: {event_type} data: {data}')
class Service:
def test(self):
SnakesBus.publish('eventTest', {'something': 'test_data'})
SnakesBus.subscribe('eventTest', MySubscriber())
Service().test()
```
Raw data
{
"_id": null,
"home_page": null,
"name": "SnakeNest",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": "Roberto Di Rienzo <roberto.dirienzo@codelithic.com>",
"keywords": "codelithic, injection, spring",
"author": null,
"author_email": "Roberto Di Rienzo <roberto.dirienzo@codelithic.com>",
"download_url": null,
"platform": null,
"description": "# SnakeNest\n\nnest.yaml\n\n```yaml\napplication:\n name: test\n spesa:\n - casa\n - sale\n - olio\n\n\nsnake:\n test:\n enable: pollo\n```\n\nExample 1\n\n```python\nfrom snakenest import *\nfrom abc import ABC, abstractmethod\n\n\nclass WorkflowManager(ABC):\n @abstractmethod\n def test(self):\n pass\n\n\n@Snake(condition={'key': 'snake.test.enable', 'value': 'salame'})\nclass Test1(WorkflowManager):\n\n def __init__(self):\n super().__init__()\n\n def test(self):\n print(\"Test1\")\n\n\n@Snake(condition={'key': 'snake.test.enable', 'value': 'pollo'})\nclass Test2(WorkflowManager):\n def __init__(self):\n super().__init__()\n\n def test(self):\n print(\"Test2\")\n\n\nclass Check:\n @Poisoned()\n def __init__(self, wf: WorkflowManager):\n wf.test()\n\n\ndef print_hi(name):\n Check()\n\n\nif __name__ == '__main__':\n Nest.initialize()\n print_hi('Clint')\n\n\n```\n\nExample 2\n\n```python\nfrom snakenest import *\n\n\n@Snake(args={\"val1\": \"10\", \"val2\": \"22\"})\nclass Config:\n def __init__(self, val1, val2):\n self.val1 = val1\n self.val2 = val2\n\n def get_val1(self):\n return self.val1\n\n def get_val2(self):\n return self.val2\n\n\n@Snake()\nclass MyCondition:\n def __init__(self):\n pass\n\n\n@Snake()\nclass Test:\n @Poisoned()\n def __init__(self, config: Config):\n self.__config = config\n print(f'Test: {self.__config.__dict__}')\n\n def hello(self, name):\n return f\"Test: Hello {name}\"\n\n def getName(self):\n return \"test_name\"\n\n\n@Snake(name='testName', args={\"q\": \"10\", \"b\": \"${application.spesa:casa}\"})\nclass Pollo:\n def __init__(self, q, b):\n self.q, self.b = q, b\n\n def hello(self, name):\n return f\"Test_named: Hello {name}\"\n\n def getName(self):\n return f'Pollo -> TestNamed: {self.q} - {self.b}'\n\n\nclass Test2:\n\n @Poisoned()\n def __init__(self, config: Config):\n self.__config = config\n print(f'Test2: {self.__config.__dict__}')\n\n @Poisoned()\n def getTestName(self, panico, name: Test):\n return name.hello(panico)\n\n @Poisoned(name='testName')\n def getTestName2(self, name): # <-- tipo non definito ma injected\n return name.getName()\n\n\ndef print_hi(name):\n t2 = Test2()\n print(f'Hi, {name}, {t2.getTestName(\"sale\")} {t2.getTestName2()} ')\n\n\nif __name__ == '__main__':\n Nest.initialize()\n print_hi('PyCharm')\n # SnakeNest.clear()\n\n```\n\nSnakeBus message\n\n```python\nclass MySubscriber(SnakeNotificationSubscriber):\n def handle_event(self, event_type, data=None):\n print(f'Received: {event_type} data: {data}')\n\n\nclass Service:\n def test(self):\n SnakesBus.publish('eventTest', {'something': 'test_data'})\n\n\nSnakesBus.subscribe('eventTest', MySubscriber())\nService().test()\n```\n",
"bugtrack_url": null,
"license": null,
"summary": "Snake Nest",
"version": "0.2.1",
"project_urls": null,
"split_keywords": [
"codelithic",
" injection",
" spring"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "31a1b137c9464c72be13812af266e7a96a8c51330d5ba43907898e6ecec81732",
"md5": "5d3264d513bca6ea7c31749460570685",
"sha256": "985ee3cf2b1eddf1de2e886b3775ddb944ab270197299b81ad4da858ffafb307"
},
"downloads": -1,
"filename": "snakenest-0.2.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "5d3264d513bca6ea7c31749460570685",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 6067,
"upload_time": "2024-04-07T06:29:36",
"upload_time_iso_8601": "2024-04-07T06:29:36.772692Z",
"url": "https://files.pythonhosted.org/packages/31/a1/b137c9464c72be13812af266e7a96a8c51330d5ba43907898e6ecec81732/snakenest-0.2.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-04-07 06:29:36",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "snakenest"
}