# -*- coding: utf-8 -*-
from setuptools import setup

packages = \
['lucidic']

package_data = \
{'': ['*']}

setup_kwargs = {
    'name': 'lucidic',
    'version': '0.1.2',
    'description': 'Lucidic is a Python dictionary utility designed to simplify dictionary operations and comparisons',
    'long_description': '# Lucidic(t) Python3 Dictionary Utility Package\n\n__NOTE: This Library is STILL IN DEV as of this latest push on 12/29/2019. The documented functionality below is functional and tested via the library\'s unit tests. Currently there is 100% test coverage for this library.__\n\n<br>\n\n## Description\n\nUsing Python dictionaries within a project is a very common practice. A majority of the web speaks in JSON, a data structure similar to, and often constructed with dictionaries if written in Python. A common use case that is encountered often is the need to compare an incoming request payload, which is generally received in JSON against a previously received payload to calculate what changes to the data have been made. It was this very use case that inspired the development of this little project. Working with AWS\'s NoSQL Dynamo DB as of late, has given way to quite a few instances where the important data from an incoming request is transformed in-flight into, and stored as, a Map data structure within Dynamo. When updates to that payload come in, there is generally a need to be able to quickly pull that data back from Dynamo, and compare it to the incoming request in order to calculate the changes in data that have occurred in order to create an update request to Dynamo, based on those changes. The last time this very use case was encountered, the decision to create a library that would easily handle the comparision between a pair of dictionaries that would be both, reusable and effective in auto generating a request to update only the change delta, gave birth to this library, Lucidic(t). Hopefully others will find Lucidic as useful as intended. In addition to simple key by key, value by value recursive comparisions, other methods such as a recursive keyword search and construction of a dict from an ordered list have also been built into the library with usage of those methods documented below. Enjoy, and please feel free to submit or request any changes/bugs/features etc. As with all things, the world is full of smart people, and there are inevitably better ways to perform the same tasks that have been constructed within this library. If things can be done more efficiently, those suggestions are more then welcome.\n\n<br><br>\n\n## Python Version\n\nThis library is compatible with Python 3.6 and higher. It may work with earlier versions of Python3 but was not tested against anything earlier then 3.6. As Python 2.x is soon to be end of life, backward compatibility was not taken into consideration.\n\n<br><br>\n\n## Installation\n\nThis library has been published to [PyPi](https://pypi.org/project/lucidic/) and can be installed via normal python package manager conventions such as [pip](https://pip.pypa.io/en/stable/) or [poetry](https://pypi.org/project/poetry/).\n\n<br>\n\n```python\npip3 install lucidic\n```\n\n <br>\n\n In order to use the library simply import it into your project once installed via pip or poetry.\n\n ```python\nfrom lucidic import Lucidic\n ```\n\n<br><br>\n\n## Instantiating a Lucidic class object\n\nA lucidic object can be instantiated via an existing Python dictionary, or as a stand alone instance resulting in an empty dictionary. The latter option\'s near future use case is to allow a new dictionary instance to be created from a list or comma separated string value.\nWhen the object is instantiated, a deep copy of the instantiation dictionary is set as the objects dictionary. This means that any modification within the Lucidic object will **NOT** alter the origin instantiation dictionary.\n\n<br>\n\n```python\nTestDict = {"Record": {"Name": "Test Dictionary", "Type": "SomeRecordTypeName"}}\nTestDict = Lucidic(TestDic)\nNewDict = Lucidic()\n```\n\n<br><br>\n\n## Attributes\n\n`.dict` = The dictionary object used to instantiate the class instance.\n\n<br>\n\n```python\nprint(TestDict.dict)\n\n{\'Record\': {\'Name\': \'Test Dictionary\', \'Type\': \'SomeRecordTypeName\'}}\n```\n\n<br><br>\n\n## Methods\n\n### `.search(keyword, strict)`\n\nThe search method allows the ability to recursively search for a keyword throughout the entire dictionary object. The method takes 2 arguments, one of which is required, the other optional.\n\n<br>\n\n- `keyword` (Required): The string value that will be searched for recursively within the lucidic instance.\n- `strict` (Optional): Flag to toggle between default loose search and exact search\n\n<br>\n\nThe strict flag toggles the difference between a loose substring search `if keyword.lower() in key/value/item.lower()` vs an exact match search `if keyword == key/value/item`.\n\nThe search utility recursively searches through nested dictionary objects as well as lists and nested lists.\n\n<br>\n\n```python\nprint(TestDict.search("Name"))\n\n[\n    {\'keypath\': [\'Record\'], \'match\': {\'Name\': \'Test Dictionary\'}},\n    {\'keypath\': [\'Record\'], \'match\': {\'Type\': \'SomeRecordTypeName\'}}\n]\n```\n\n<br>\n\n```python\nprint(TestDict.search("Name", strict=True))\n\n[\n    {\'keypath\': [\'Record\'], \'match\': {\'Name\': \'Test Dictionary\'}}\n]\n```\n\n<br>\n\nAs you can see, the search results come back as a list of dict objects. Each dict object contains the keypath of the keyword match occurrence as well as the match occurrence itself. So in the example above, during the loose search, 2 results were returned. Both results were found nested in the \'Record\' key, and the match shows the key:value pair where the match was found. If your dictionary object contains nested lists as well, then the result will take that into account as in the the example:\n\n<br>\n\n```python\nTestDict = {\n    "Records": [\n        {"Name": "Record1", "Keywords": ["one", "two", "three"]},\n        {"Name": "Record2", "Keywords": ["three", "four", "five"]},\n        {"Name": "Record3", "Keywords": [\n            {"ListItem": "One"},\n            {"ListItem": "Two"},\n            {"ListItem": "Three"},\n            {"ListItem": [["One"], ["One", "Two"], ["One", "Two", "Three"]]}\n        ]}\n    ]\n}\nTestDict = Lucidic(TestDict)\nprint(TestDict.search("Three"))\n```\n\n<br>\n\n```python\n[\n    {\'keypath\': [\'Records[0]\'], \'match\': {\'Keywords[2]\': \'three\'}},\n    {\'keypath\': [\'Records[1]\'], \'match\': {\'Keywords[0]\': \'three\'}},\n    {\'keypath\': [\'Records[2]\', \'Keywords[2]\'], \'match\': {\'ListItem\': \'Three\'}},\n    {\'keypath\': [\'Records[2]\', \'Keywords[3]\', \'ListItem[2]\'], \'match\': {\'ListItem[2][2]\': \'Three\'}}\n]\n```\n\n<br>\n\nIn this example we have a variety of nested structures within our referenced dict. In the event that the search term is found within a list item, the keypath will contain both the list item parent dict key, as well as a path through the list to the matched keyword occurrence.\n\nLooking at the last result as an example we can see that the path to the matched keyword is as follows:\n\n`TestDict` = Dict Object, with \'Records\' key that contains list as a value. <br>\n`TestDict.Records[2]` which is the list\'s index, or 3rd item in the list contains a nested dict object containing \'Name\' key and a \'Keywords\' key that has another list object as the value. <br>\n`TestDict.Records[2].Keywords[3]` is the 4th item within that list, that contains another nested dict object that contains a \'ListItem\' key, that holds a list of lists as the value. <br>\n`TestDict.Records[2].Keywords[3].ListItem[2]` or the 3rd list within the list of lists that contains string value items. <br>\n`TestDict.Records[2].Keywords[3].ListItem[2]` contains our keyword match for the string value within that nested list at `index [2]`. <br>\n\n<br>\n\nThe keypath returns were constructed in a list object as a way to allow future methods within the library to be passed this format and easily construct a matching dictionary schema, which is useful when performaing a comparison and creating an update dict containing just the changed keys/values.\n\n<br><br>\n\n### `.replaceNull(keyword)`\n\nThe replaceNull method will recursively go through the instantiated objects dictionary and replace any values within the dictionary that are set to None, Null, Nil, or contain an empty string value (""). This function is especially useful when dealing with NoSQL databases such as AWS DynamoDB, in which Dynamo does not allow those values to be added to a table. The keword becomes the value of any occurrence of a None, Null, Nil, or empty string value currently set for keys within the dictionary. Keyword is optional, if left blank, then by default it will be set to `Undefined`.\n\n<br>\n\n- `keyword` (Optional): The string value that will be used as a replacement to any keys value that contains None, Null, Nil, or an empty string ("").\n\n<br>\n\n```python\n# Print the objects dictionary before executing the replaceNull method.\nprint(TestDict.dict)\n\n{\n    "FirstTierKey1": "FirstTierValue",\n    "FirstTierKey2": "Null",\n    "FirstTierKey3": {\n        "SecondTierKey1": "SomeValue",\n        "SecondTierKey2": "Nil",\n        "SecondTierKey3": "",\n        "SecondTierKey4": {\n            "ThirdTierKey1": "null",\n            "ThirdTierKey2": [\n                {"FourthListTierKey1": "nil"},\n                {"FourthListTierKey2": ""},\n                {"FourthListTierKey3": "FourthListTierValue3"}\n            ]\n        }\n    }\n}\n```\n\n<br>\n\n```python\nLucidict.replaceNull("UnKnown")\n\n# Or to assign the result dict as a new variable\nSanitizedDict = Lucidict.replaceNull("UnKnown")\n```\n\n<br>\n\n```python\n# Print the objects dictionary after the replaceNull method has been executed.\nprint(TestDict.dict)\n\n{\n    "FirstTierKey1": "FirstTierValue",\n    "FirstTierKey2": "UnKnown",\n    "FirstTierKey3": {\n        "SecondTierKey1": "SomeValue",\n        "SecondTierKey2": "UnKnown",\n        "SecondTierKey3": "UnKnown",\n        "SecondTierKey4": {\n            "ThirdTierKey1": "UnKnown",\n            "ThirdTierKey2": [\n                {"FourthListTierKey1": "UnKnown"},\n                {"FourthListTierKey2": "UnKnown"},\n                {"FourthListTierKey3": "FourthListTierValue3"}\n            ]\n        }\n    }\n}\n```\n\n<br><br>\n\n### `.replaceKey(key_search, replace_value)`\n\nThe replaceKey method will recursively go through the instantiated objects dictionary and if any of the dictionaries keys match the given `key_search` value, then the key will be renamed to the value set in `replace_value`.\n\n<br>\n\n__NOTE: This method will replace *ALL* occurrences of the matched key. If there are various keys within the objects dictionary that are named with the value set in `key_search`, they will be renamed to the value set in `replace_value`.__\n\n<br>\n\n- `key_search` (Required): The value to evaluate and attempt to match to each key within the objects dictionary attribute.\n- `replace_value` (Required): The value to change the matched key to within the objects dictionary attribute.\n\n<br>\n\n```python\n# Print the objects dictionary before executing the replaceKey method.\nprint(TestDict.dict)\n\n{\n    "FirstTierKey1": "FirstTierValue",\n    "FirstTierKey2": "Null",\n    "FirstTierKey3": {\n        "SecondTierKey1": "SomeValue",\n        "SecondTierKey2": "Nil",\n        "SecondTierKey3": "",\n        "SecondTierKey4": {\n            "ThirdTierKey1": "null",\n            "ThirdTierKey2": [\n                {"FourthListTierKey1": "nil"},\n                {"FourthListTierKey2": ""},\n                {"FourthListTierKey3": "FourthListTierValue3"}\n            ]\n        }\n    }\n}\n```\n\n<br>\n\n```python\nLucidict.replaceKey("FourthListTierKey3", "ChangedKey1")\n\n# Or to assign the result dict as a new variable\nKeyReplace = Lucidict.replaceKey("FourthListTierKey3", "ChangedKey1")\n```\n\n<br>\n\n```python\n# Print the objects dictionary after the replaceKey method has been executed.\nprint(TestDict.dict)\n\n{\n    "FirstTierKey1": "FirstTierValue",\n    "FirstTierKey2": "Null",\n    "FirstTierKey3": {\n        "SecondTierKey1": "SomeValue",\n        "SecondTierKey2": "Nil",\n        "SecondTierKey3": "",\n        "SecondTierKey4": {\n            "ThirdTierKey1": "null",\n            "ThirdTierKey2": [\n                {"FourthListTierKey1": "nil"},\n                {"FourthListTierKey2": ""},\n                {"ChangedKey1": "FourthListTierValue3"}\n            ]\n        }\n    }\n}\n```\n\n<br><br>\n\n### `.replaceValue(val_search, replace_value)`\n\nThe replaceValue method will recursively go through the instantiated objects dictionary and if any key or property values match the given `val_search` value, then the key or property\'s value will be modified to the value set in `replace_value`.\n\n<br>\n\n__NOTE: This method will replace *ALL* occurrences of the matched value. If there are various keys within the objects dictionary that contain and match the specified `val_search` value, they will all be modified to the value set in `replace_value`.__\n\n<br>\n\n- `val_search` (Required): The value to evaluate and attempt to match to each keys currently set value within the objects dictionary attribute.\n- `replace_value` (Required): The value to change the matched keys currently set value to within the objects dictionary attribute.\n\n<br>\n\n```python\n# Print the objects dictionary before executing the replaceValue method.\nprint(TestDict.dict)\n\n{\n    "FirstTierKey1": "FirstTierValue",\n    "FirstTierKey2": "Null",\n    "FirstTierKey3": {\n        "SecondTierKey1": "SomeValue",\n        "SecondTierKey2": "Nil",\n        "SecondTierKey3": "",\n        "SecondTierKey4": {\n            "ThirdTierKey1": "null",\n            "ThirdTierKey2": [\n                {"FourthListTierKey1": "nil"},\n                {"FourthListTierKey2": ""},\n                {"FourthListTierKey3": "FourthListTierValue3"}\n            ]\n        }\n    }\n}\n```\n\n<br>\n\n```python\nLucidict.replaceValue("FourthListTierValue3", "ChangedVal1")\n\n# Or to assign the result dict as a new variable\nKeyReplace = Lucidict.replaceValue("FourthListTierValue3", "ChangedVal1")\n```\n\n<br>\n\n```python\n# Print the objects dictionary after the replaceValue method has been executed.\nprint(TestDict.dict)\n\n{\n    "FirstTierKey1": "FirstTierValue",\n    "FirstTierKey2": "Null",\n    "FirstTierKey3": {\n        "SecondTierKey1": "SomeValue",\n        "SecondTierKey2": "Nil",\n        "SecondTierKey3": "",\n        "SecondTierKey4": {\n            "ThirdTierKey1": "null",\n            "ThirdTierKey2": [\n                {"FourthListTierKey1": "nil"},\n                {"FourthListTierKey2": ""},\n                {"ChangedKey1": "ChangedVal1"}\n            ]\n        }\n    }\n}\n```\n\n<br><br>\n',
    'author': 'Rich Nason',
    'author_email': 'rnason@cloudmage.io',
    'maintainer': None,
    'maintainer_email': None,
    'url': 'https://github.com/TheCloudMage/PyPkgs-Lucidic',
    'packages': packages,
    'package_data': package_data,
    'python_requires': '>=3.6,<4.0',
}


setup(**setup_kwargs)
