{
"info": {
"author": "Handwriting.io",
"author_email": "support@handwriting.io",
"bugtrack_url": null,
"classifiers": [
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Natural Language :: English",
"Programming Language :: Python",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5"
],
"description": "Handwriting.io Python Client\n============================\n\n.. image:: https://img.shields.io/circleci/project/handwritingio/python-client.svg\n :target: https://circleci.com/gh/handwritingio/python-client\n\n.. image:: https://img.shields.io/pypi/v/handwritingio.svg\n :target: https://pypi.python.org/pypi/handwritingio\n\n.. image:: https://img.shields.io/pypi/pyversions/handwritingio.svg\n\n.. image:: https://img.shields.io/pypi/l/handwritingio.svg\n\n\nInstallation\n------------\n\n.. code-block:: bash\n\n $ pip install handwritingio\n\n\nBasic Example\n-------------\n\nSet up the client, render an image, and write it to a file:\n\n.. code-block:: python\n\n import handwritingio\n\n hwio = handwritingio.Client('KEY', 'SECRET')\n png = hwio.render_png({\n 'handwriting_id': '2D5S46A80003', # found in our catalog or by listing handwritings\n 'text': 'Handwriting with Python!',\n 'height': 'auto',\n })\n with open('handwriting.png', 'wb') as f:\n f.write(png)\n\nIf all goes well, this should create an image similar to the following:\n\n.. image:: https://d2igm8ue20pook.cloudfront.net/python-client/handwriting.png\n\n\nAdvanced Examples\n-----------------\n\nList all handwritings, paging through the results as necessary:\n\n.. code-block:: python\n\n import handwritingio\n\n hwio = handwritingio.Client('KEY', 'SECRET')\n all_handwritings = [] # we'll add all of the results to this list\n limit = 100 # number of handwritings to get per page\n offset = 0 # starting index\n while True:\n page_of_handwritings = hwio.list_handwritings({\n 'limit': limit,\n 'offset': offset,\n })\n if not page_of_handwritings:\n # We've exhausted the listing, so we're done\n break\n all_handwritings.extend(page_of_handwritings)\n offset += limit\n # all_handwritings now contains every handwriting available\n\n\nIf you don't need all of the (currently 200+) handwritings for your application,\nyou could simply fetch the five \"most cursive\" handwritings, for example:\n\n.. code-block:: python\n\n import handwritingio\n\n hwio = handwritingio.Client('KEY', 'SECRET')\n handwritings = hwio.list_handwritings({\n 'order_by': 'rating_cursivity',\n 'order_dir': 'desc',\n 'limit': 5,\n })\n\nRender a PNG and manipulate it with `PIL `_:\n\n.. code-block:: python\n\n from cStringIO import StringIO\n\n import handwritingio\n from PIL import Image\n\n hwio = handwritingio.Client('KEY', 'SECRET')\n png = hwio.render_png({\n 'handwriting_id': '2D5S46A80003', # found in our catalog or by listing handwritings\n 'text': 'Handwriting with Python!',\n 'height': 'auto',\n })\n # Image expects a file-like object, so wrap the image in StringIO:\n im = Image.open(StringIO(png))\n # Rotate the image by 180 degrees:\n im = im.rotate(180, expand=True)\n # Save it to a file:\n im.save('handwriting_upside_down.png')\n\nWhich should create the file:\n\n.. image:: https://d2igm8ue20pook.cloudfront.net/python-client/handwriting_upside_down.png\n\nRender a PDF, with a CMYK color for the text:\n\n.. code-block:: python\n\n import handwritingio\n\n hwio = handwritingio.Client('KEY', 'SECRET')\n pdf = hwio.render_pdf({\n 'handwriting_id': '2D5S46A80003', # found in our catalog or by listing handwritings\n 'text': 'Handwriting with Python!',\n 'height': 'auto',\n 'handwriting_color': '(1, 0.5, 0, 0.2)',\n })\n with open('handwriting.pdf', 'wb') as f:\n f.write(pdf)\n\nIf something goes wrong with a request, an exception will be raised:\n\n.. code-block:: python\n\n import handwritingio\n\n hwio = handwritingio.Client('KEY', 'SECRET')\n pdf = hwio.render_pdf({\n 'handwriting_id': '2D5S46A80003',\n 'text': 'Handwriting with Python!',\n 'height': 'auto',\n 'handwriting_color': 'cheesecake',\n 'width': 'double wide',\n })\n\n::\n\n Traceback (most recent call last):\n File \"tester.py\", line 9, in \n 'width': 'double wide',\n File \"build/bdist.linux-x86_64/egg/handwritingio/__init__.py\", line 145, in render_pdf\n File \"build/bdist.linux-x86_64/egg/handwritingio/__init__.py\", line 109, in _hit\n handwritingio.ValidationError: field: width, width unable to parse: \"double wide\"\n\nBut, there's more than one thing wrong with that request. We can see all of the\nerrors by catching the exception and inspecting the ``errors`` attribute:\n\n.. code-block:: python\n\n import handwritingio\n\n hwio = handwritingio.Client('KEY', 'SECRET')\n try:\n pdf = hwio.render_pdf({\n 'handwriting_id': '2D5S46A80003',\n 'text': 'Handwriting with Python!',\n 'height': 'auto',\n 'handwriting_color': 'cheesecake',\n 'width': 'double wide',\n })\n except handwritingio.ValidationError as e:\n print e.errors\n\n::\n\n [{u'field': u'width', u'error': u'width unable to parse: \"double wide\"'},\n {u'field': u'handwriting_color', u'error': u'handwriting_color must be valid CMYK'}]\n\n\nReference\n---------\n\nSee the `API Documentation `_ for details on\nall endpoints and parameters. For the most part, the ``Client`` passes the\nparameters through to the API directly.\n\nThe endpoints map to client methods as follows:\n\n- `GET /handwritings `_ -> ``Client.list_handwritings([params])``\n- `GET /handwritings/{id} `_ -> ``Client.get_handwriting(handwriting_id)``\n- `GET /render/png `_ -> ``Client.render_png(params)``\n- `GET /render/pdf `_ -> ``Client.render_pdf(params)``\n\nVersion Numbers\n---------------\n\nVersion numbers for this package work slightly differently than standard\n`semantic versioning `_. For this package, the ``major``\nversion number will match the Handwriting.io API version number, and the\n``minor`` version will be incremented for any breaking changes to this package.\nThe ``patch`` version will be incremented for bug fixes and changes that add\nfunctionality only.\n\nFor this reason, we recommend that you pin this dependency to the\n**minor version**, for example, in your ``requirements.txt`` or ``setup.py``,\nuse::\n\n handwritingio>=1.0<1.1\n\n\nIssues\n------\n\nPlease open an issue on `Github `_\nor `contact us `_ directly for help with any\nproblems you find.",
"description_content_type": null,
"docs_url": null,
"download_url": "UNKNOWN",
"downloads": {
"last_day": -1,
"last_month": -1,
"last_week": -1
},
"home_page": "https://github.com/handwritingio/python-client",
"keywords": null,
"license": "MIT License",
"maintainer": null,
"maintainer_email": null,
"name": "handwritingio",
"package_url": "https://pypi.org/project/handwritingio/",
"platform": "UNKNOWN",
"project_url": "https://pypi.org/project/handwritingio/",
"project_urls": {
"Download": "UNKNOWN",
"Homepage": "https://github.com/handwritingio/python-client"
},
"release_url": "https://pypi.org/project/handwritingio/1.0.0/",
"requires_dist": null,
"requires_python": null,
"summary": "Handwriting.io API client.",
"version": "1.0.0"
},
"last_serial": 2064349,
"releases": {
"1.0.0": [
{
"comment_text": "",
"digests": {
"md5": "6527cca7b52b5c8b836190c0084924b8",
"sha256": "17ea991e5df19c4923feaee8b51be6bada6b08409f23ca84ffb978bd9655adbe"
},
"downloads": -1,
"filename": "handwritingio-1.0.0.tar.gz",
"has_sig": false,
"md5_digest": "6527cca7b52b5c8b836190c0084924b8",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 7284,
"upload_time": "2016-04-14T18:56:13",
"url": "https://files.pythonhosted.org/packages/6e/09/ef9b4c94032ece947a9549a09cf1c3afea637701cc37863c38cc446d068f/handwritingio-1.0.0.tar.gz"
}
]
},
"urls": [
{
"comment_text": "",
"digests": {
"md5": "6527cca7b52b5c8b836190c0084924b8",
"sha256": "17ea991e5df19c4923feaee8b51be6bada6b08409f23ca84ffb978bd9655adbe"
},
"downloads": -1,
"filename": "handwritingio-1.0.0.tar.gz",
"has_sig": false,
"md5_digest": "6527cca7b52b5c8b836190c0084924b8",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 7284,
"upload_time": "2016-04-14T18:56:13",
"url": "https://files.pythonhosted.org/packages/6e/09/ef9b4c94032ece947a9549a09cf1c3afea637701cc37863c38cc446d068f/handwritingio-1.0.0.tar.gz"
}
]
}