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

packages = \
['pydispix']

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

install_requires = \
['colorama>=0.4.4,<0.5.0',
 'matplotlib>=3.4.2,<3.5.0',
 'pillow>=8.2.0,<8.3.0',
 'requests>=2.25.1,<2.26.0']

setup_kwargs = {
    'name': 'pydispix',
    'version': '1.2.1',
    'description': "API wrapper for python-discord's pixels.",
    'long_description': '# PyDisPix\n\n[![made-with-python](https://img.shields.io/badge/Made%20with-Python%203.8+-ffe900.svg?longCache=true&style=flat-square&colorB=00a1ff&logo=python&logoColor=88889e)](https://www.python.org/)\n[![MIT](https://img.shields.io/badge/Licensed%20under-MIT-red.svg?style=flat-square)](./LICENSE)\n[![Validation](https://github.com/ItsDrike/pydispix/actions/workflows/validation.yml/badge.svg)](https://github.com/ItsDrike/pydispix/actions/workflows/validation.yml)\n\nA simple wrapper around [Python Discord Pixels](https://pixels.pythondiscord.com).\nCheck it out on [PyPI](https://pypi.org/project/pydispix/).\n\n## Examples\n\n### Main usage\n\n```py\nimport pydispix\n\n# Create a client with your token.\nclient = pydispix.Client(\'my-auth-token\')\n\n# Fetch a specific pixel.\nprint(client.get_pixel(4, 10))\n\n# Draw a pixel.\nclient.put_pixel(50, 10, \'cyan\')\nclient.put_pixel(1, 5, pydispix.Color.BLURPLE)\nclient.put_pixel(100, 4, \'93FF00\')\nclient.put_pixel(44, 0, 0xFF0000)\nclient.put_pixel(8, 54, (255, 255, 255))\n```\n\n### Canvas\n\nWe can also work with the whole pixels canvas\n\n```py\n# Fetch the canvas\ncanvas = client.get_canvas()\n\n# Show the canvas using matplotlib, this will include coordinates\ncanvas.show()\n\n# Save the canvas to a file\ncanvas.save(\'canvas.png\')\n\n# And access pixels from it.\nprint(canvas[4, 10])\n```\n\n### Draw image from png\n\nLoad an image:\n\n```py\nfrom PIL import Image\n\nim = Image.open(\'pretty.png\')\nad = pydispix.AutoDrawer.load_image(client, (5, 40), im, scale=0.1)\nad.draw()\n```\n\nAuto-draw will avoid colouring already correct pixels, for efficiency.\n\nYou can also run this continually with `guard=True` which makes sure that after your image\nis drawn, this keeps running to check if it haven\'t been tampered with, and fixes all non-matching\npixels.\n\n```py\nad.draw(guard=True, guard_delay=2)\n```\n\n`guard_delay` is the delay between each full iteration of all pixels. We need to wait since\nlooping without any changes is almost instant in python, and we don\'t want to put cpu through that\nstress for no reason\n\n### Draw multiple images\n\nYou can also draw multiple images one by one\n\n```py\nfrom PIL import Image\nfrom pydispix import Client, AutoDrawer\n\nclient = Client("pixels_api_token")\n\npositions = [(52, 14), (120, 54)]\nimages = [Image("img1.png"), Image("img2.png")]\nscales = [0.5, 1]\n\nad = AutoDrawer.load_images(client, positions, images, scales, one_by_one=True)\nad.draw()\n```\n\nThis will proceed to start drawing the images in order they were passed. You could also\nset `one_by_one` to `False`, which would cause the images to instead be drawn by pixel\nfrom each, i.e. 1st pixel from img1, 1st pixel from img2, 2nd from img1, 2nd from img2, ...\n\n### Collaborate on image drawing\n\nYou can share the load of drawing a single image between multiple joined clients.\nThis will mean each client will only ever work on it\'s part of given image, both when guarding and drawing it.\n\n```py\nfrom PIL import Image\nfrom pydispix import DistributedClient, DistributedAutoDrawer\n\n# First machine\nmulti_client = DistributedClient(\'pixels_api_key\', total_tasks=2 ,controlled_tasks=[0])\n# Second machine\n#multi_client = MultiClient(\'pixels_api_key2\', total_tasks=2 ,controlled_tasks=[1])\n\nimage = Image.open(\'my_img.png\')\nauto_drawer = DistributedAutoDrawer.load_image(multi_client, (2, 10), image, scale=0.8)\nauto_drawer.draw(guard=True)\n```\n\n`total_tasks` is the number of clients you will have in total, i.e. the number of workers\nfor shared tasks. It\'s how many groups will the shared pixels be split into.\n\n`controlled_tasks` are the groups controlled by this `MultiClient` instance. This is usually\nonly 1 task, but you can specify multiple tasks and split the code further.\n\n### Churches\n\nChurches are groups of people collaborating on some image, or set of images on the canvas.\nIt\'s basically a big botnet of people. Most popular church is currently the\n[Church Of Rick](https://pixel-tasks.scoder12.repl.co/). Churches provide it\'s members with\ntasks to fill certain pixels, and the members finish those tasks and report it back to the church.\nThis is how you run a single task like this with Church of Rick:\n\n```py\nfrom pydispix.churches import RickChurchClient\n\nclient = RickChurchClient(pixels_api_token, rick_church_api_token)\nclient.run_task(show_progress=True)\n```\n\nChurch of SQLite is also supported, and they don\'t require an API key, it is free for everyone:\n\n```py\nfrom pydispix.churches import SQLiteChurchClient\n\nclient = SQLiteChurchClient(pixels_api_token)\nclient.run_task()\n```\n\n### Continually running church tasks\n\nIf you wish to keep running church tasks continually in a loop, make sure to use `client.run_tasks()`,\navoid `client.run_task()` since it doesn\'t handle any errors specific to the used church,\n`client.run_tasks()` will handle these errors cleanly and log the problems if some ocurred.\n\nNote: `client.run_tasks()` only handles known exceptions, there might still be some exceptions that a church\ncould raise which aren\'t handled. If you manage to find one make sure to file an issue about it.\n\nExample of safe continual script to keep running church tasks on your machine:\n\n```py\nimport pickle\nimport time\nfrom pydispix.churches import RickChurchClient\n\nclient = RickChurchClient(pixels_api_token, rick_church_api_token)\n\nexception_amt = 0\nwhile True:\n    try:\n        client.run_tasks(show_progress=True)\n    except Exception as exc:\n        print(f"Exception ocurred: {exc} (#{exception_amt})")\n        with open(f"exception{exception_amt}.pickle", "wb") as f:\n            pickle.dump(exc, f)\n        exception_amt += 1\n        time.sleep(5)\n```\n\nThere is still exception handling here, but it shouldn\'t capture any, it\'s only here since you\'ll\nlikely not be there to monitor the process all the time, so even in the rare case that something\nwere to occur, the program will keep running and the exception will stored with pickle.\n\nIf you see that this happened (if you find `exceptionX.pickle` files in your working directory),\nload the pickled exception and examine what exactly happened. Upload the traceback with the issue.\n\n```py\nimport pickle\n\nwith open("exception0.pickle", "rb") as f:\n  exc = pickle.load(f)\n\nraise exc\n```\n\n**Important: do not upload the pickle file anywhere, it contains the request, which includes your\nAPI keys, uploading the pickled file would inevitable lead to leaked API key.**\n\n### Other churches\n\nYou can also implement your own church according to it\'s specific API requirements, if you\'re\ninterested in doing this, check the [church.py](pydispix/church.py) and how the specific churches\nare implemented using it: [churches.py](pydispix/churches.py).\n\nIf you do end up implementing it, feel free to also open a pull request and add it, if the church\nis popular enough, you have a good chance of it being added to official `pydispix`.\n\n### Progress bars\n\nEvery request that has rate limits can now display a progress bar while it\'s sleeping on cooldown:\n\n```py\npixel = client.get_pixel(0, 0, show_progress=True)\ncanvas = client.get_canvas(show_progress=True)\nclient.put_pixel(52, 10, "FFFFFF", show_progress=True)\n```\n\nhttps://user-images.githubusercontent.com/20902250/119607092-418e4200-bde3-11eb-9ac5-4e455ffd47c2.mp4\n\n### Logging\n\nTo see logs, you can set the `DEBUG` environment variable, which changes the loglevel from `logging.INFO` to `logging.DEBUG`\nYou can also do this manually by executing:\n\n```py\nimport logging\n\nlogger = logging.getLogger("pydispix")\nlogger.setLevel(logging.DEBUG)\n```\n',
    'author': 'ItsDrike',
    'author_email': 'itsdrikeofficial@gmail.com',
    'maintainer': None,
    'maintainer_email': None,
    'url': 'https://github.com/ItsDrike/pydispix',
    'packages': packages,
    'package_data': package_data,
    'install_requires': install_requires,
    'python_requires': '>=3.8.0,<3.9.0',
}


setup(**setup_kwargs)
