<p align="center">
<a href="https://github.com/luigi-dv/result4utility"><img src="https://raw.githubusercontent.com/Luigi-DV/result4utility/master/assets/img/logo-green.png" alt="Result4Utility Logo"></a>
</p>
<p align="center">
<em>Result4Utility, easy to use, fast to implement, ready for production</em>
</p>
The module contains interesting features for APIs endpoint creation.
With some interesting decorators.
---
**Documentation**: <a href="https://github.com/luigi-dv/result4utility" target="_blank">https://github.com/luigi-dv/result4utility </a>
**Source Code**: <a href="https://github.com/luigi-dv/result4utility" target="_blank">https://github.com/luigi-dv/result4utility </a>
---
## Installation
```
pip install result4utility
```
## Examples
### __Result__
A Structure for dynamics models to encapsulate values.
When select an Error result type, the property HasErrors take true value.
__Use Case:__
```py
from result4utility.result import Result
from result4utility.result import ResultOperationType as resultType
# Initialize the Result Class
response = Result()
# Declare the model
model = {'User':'john.doe', 'Name':'John', 'Surname':'Doe'}
# Setting up the value of the response content with the model
response.content = model
# Adding results to our created response
response.add_result(message='Successfully Request', result_type=resultType.SUCCESS)
```
### __Reader__
This class provides a dictionary reader functionality using attributes.
__Use Case:__
```py
from result4utility.dictionary import Reader
# Declare the dictionary to read
dictionary_test = {
"primary_entry":"primary test data",
"secondary_entry" : {
"secondary_entry_1":"secondary test data 1",
"secondary_entry_2":{
"secondary_entry_2_1":"secondary test data 2.1",
}
}
}
# Setting up the Reader Object
dictionary = Reader(config_file=dictionary_test)
# Read the values
test_1 = dictionary.primary_entry.get()
test_2 = dictionary.secondary_entry.secondary_entry_2.secondary_entry_2_1.get()
# Print the values
print(test_1)
print(test_2)
```
### __Tools__
Two methods for dictionary operations.
#### __Convert from object to dictionary:__
```py
from result4utility.tools import Tools
class Test(object):
index:int
name:str
def __init__(self, index_input:int, name_input:str):
self.index=index_input
self.name=name_input
# Define the object to test
object_test:object = Test(1,'John')
# Initialize the Tool class
tool = Tools()
# Convert the Object to Dictionary
result:dict = tool.dictionary_from_object(model=object_test)
# Output
print ({'index':1, 'name':'John'})
```
> As you can see we are doing the object conversion over a new initialized object.
> Operations will not take actions over your main Objects.
#### __Remove properties of dictionary:__
```py
from result4utility.tools import Tools
class Test(object):
index:int
name2:str
def __init__(self, index_input:int, name_input:str):
self.index=index_input
self.name=name_input
# Initialize the Tool class
tool = Tools()
# Create new Test Class Object
object_test:object = Test(1,'John')
# Convert the Object to Dictionary
dictionary_test:dict = tool.dictionary_from_object(model=Test)
# Remove the dictionary property
result:dict = tool.remove_property(target=dictionary_test, props=['index'])
# Output
print({'name':'John'})
```
Raw data
{
"_id": null,
"home_page": "https://github.com/luigi-dv/result4utility",
"name": "result4utility",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "Restful,Rest,Util,Tools",
"author": "Luigelo Davila Vilchez",
"author_email": "luigelo@ldvloper.com",
"download_url": "https://files.pythonhosted.org/packages/5e/f8/82bbd6bc1def54c7ac5fde444d6ff921e5e74b256451041c93715df7eaac/result4utility-0.1.3.tar.gz",
"platform": null,
"description": "<p align=\"center\">\r\n <a href=\"https://github.com/luigi-dv/result4utility\"><img src=\"https://raw.githubusercontent.com/Luigi-DV/result4utility/master/assets/img/logo-green.png\" alt=\"Result4Utility Logo\"></a>\r\n</p>\r\n<p align=\"center\">\r\n <em>Result4Utility, easy to use, fast to implement, ready for production</em>\r\n</p>\r\n\r\nThe module contains interesting features for APIs endpoint creation. \r\nWith some interesting decorators.\r\n\r\n---\r\n\r\n**Documentation**: <a href=\"https://github.com/luigi-dv/result4utility\" target=\"_blank\">https://github.com/luigi-dv/result4utility </a>\r\n\r\n**Source Code**: <a href=\"https://github.com/luigi-dv/result4utility\" target=\"_blank\">https://github.com/luigi-dv/result4utility </a>\r\n\r\n---\r\n\r\n## Installation\r\n```\r\npip install result4utility\r\n```\r\n\r\n\r\n## Examples\r\n\r\n### __Result__\r\n\r\nA Structure for dynamics models to encapsulate values. \r\n\r\nWhen select an Error result type, the property HasErrors take true value.\r\n\r\n\r\n__Use Case:__\r\n\r\n```py\r\nfrom result4utility.result import Result\r\nfrom result4utility.result import ResultOperationType as resultType\r\n\r\n# Initialize the Result Class\r\nresponse = Result()\r\n\r\n# Declare the model\r\nmodel = {'User':'john.doe', 'Name':'John', 'Surname':'Doe'}\r\n\r\n# Setting up the value of the response content with the model\r\nresponse.content = model\r\n\r\n# Adding results to our created response\r\nresponse.add_result(message='Successfully Request', result_type=resultType.SUCCESS)\r\n```\r\n\r\n### __Reader__\r\n\r\nThis class provides a dictionary reader functionality using attributes.\r\n\r\n__Use Case:__\r\n\r\n```py\r\nfrom result4utility.dictionary import Reader\r\n\r\n# Declare the dictionary to read\r\ndictionary_test = {\r\n \"primary_entry\":\"primary test data\",\r\n \"secondary_entry\" : {\r\n \"secondary_entry_1\":\"secondary test data 1\",\r\n \"secondary_entry_2\":{\r\n \"secondary_entry_2_1\":\"secondary test data 2.1\",\r\n } \r\n }\r\n}\r\n\r\n# Setting up the Reader Object\r\ndictionary = Reader(config_file=dictionary_test)\r\n\r\n# Read the values\r\ntest_1 = dictionary.primary_entry.get()\r\ntest_2 = dictionary.secondary_entry.secondary_entry_2.secondary_entry_2_1.get()\r\n\r\n# Print the values\r\nprint(test_1)\r\nprint(test_2)\r\n```\r\n\r\n### __Tools__\r\n\r\nTwo methods for dictionary operations.\r\n\r\n\r\n#### __Convert from object to dictionary:__\r\n\r\n```py\r\nfrom result4utility.tools import Tools\r\n\r\nclass Test(object):\r\n index:int\r\n name:str\r\n def __init__(self, index_input:int, name_input:str):\r\n self.index=index_input\r\n self.name=name_input\r\n \r\n# Define the object to test \r\nobject_test:object = Test(1,'John')\r\n\r\n# Initialize the Tool class\r\ntool = Tools()\r\n\r\n# Convert the Object to Dictionary\r\nresult:dict = tool.dictionary_from_object(model=object_test)\r\n\r\n# Output\r\nprint ({'index':1, 'name':'John'})\r\n```\r\n\r\n> As you can see we are doing the object conversion over a new initialized object.\r\n> Operations will not take actions over your main Objects.\r\n\r\n#### __Remove properties of dictionary:__\r\n\r\n```py\r\nfrom result4utility.tools import Tools\r\n\r\nclass Test(object):\r\n index:int\r\n name2:str\r\n def __init__(self, index_input:int, name_input:str):\r\n self.index=index_input\r\n self.name=name_input\r\n \r\n# Initialize the Tool class\r\ntool = Tools()\r\n\r\n# Create new Test Class Object \r\nobject_test:object = Test(1,'John')\r\n\r\n# Convert the Object to Dictionary\r\ndictionary_test:dict = tool.dictionary_from_object(model=Test)\r\n\r\n# Remove the dictionary property\r\nresult:dict = tool.remove_property(target=dictionary_test, props=['index'])\r\n\r\n# Output\r\nprint({'name':'John'})\r\n```\r\n",
"bugtrack_url": null,
"license": "",
"summary": "Result For Utility Tools",
"version": "0.1.3",
"split_keywords": [
"restful",
"rest",
"util",
"tools"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "5ef882bbd6bc1def54c7ac5fde444d6ff921e5e74b256451041c93715df7eaac",
"md5": "c0937992d961c469284bc7f1177eca0c",
"sha256": "6d609bb60ca73a364ebe20088abdfb57a5a45bda7cc5093647aa35db34e3ff03"
},
"downloads": -1,
"filename": "result4utility-0.1.3.tar.gz",
"has_sig": false,
"md5_digest": "c0937992d961c469284bc7f1177eca0c",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 9372,
"upload_time": "2023-02-10T16:13:41",
"upload_time_iso_8601": "2023-02-10T16:13:41.389438Z",
"url": "https://files.pythonhosted.org/packages/5e/f8/82bbd6bc1def54c7ac5fde444d6ff921e5e74b256451041c93715df7eaac/result4utility-0.1.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-02-10 16:13:41",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "luigi-dv",
"github_project": "result4utility",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "result4utility"
}