{ "info": { "author": "Micha\u0142 Kali\u0144ski", "author_email": "", "bugtrack_url": null, "classifiers": [ "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Topic :: Utilities" ], "description": "=======\nMorphys\n=======\n\n**Morphys** is a simple, small library providing utilities for easy smart\nconversions between ``unicode`` and ``bytes`` types.\n\nIn Python 2, the treatment of ``unicode`` and ``bytes`` objects is a potential\nsource of many surprising and annoying errors, should a non-ASCII character\nappear anywhere in a string.\n\nThe two types are completely equivalent if only ASCII characters are used, and\nmany libraries treat them as such, while others are more vigilant about which\ntype they accept. Some can even return one or the other type of string from the\nsame function depending on the content (for example, the standard library\n``json`` module).\n\n**Morphys** is meant to help with cases where types of strings handled by\nlibraries are inconsistent or undocumented. Or where simply both types of\nstring can appear, but should be coerced to the same type before being handled.\n\n\nConversion functions\n====================\n\n**Morphys** provides two functions for smart conversions to ``unicode`` or\n``bytes``. They just return their argument unchanged if it's already the right\ntype and can also convert any object defining the ``__unicode__`` (or\n``__str__`` in Python 3) \"magic\" method.\n\n``ensure_bytes(obj, encoding=None)``\n Return ``obj`` as a ``bytes`` object, if necessary encoding it using\n ``encoding``.\n\n``ensure_unicode(obj, encoding=None)``\n Return ``obj`` as an ``unicode`` object, if necessary decoding it using\n ``encoding``.\n\nSee docstrings in the module for more detailed description of the functions.\n\n\nLazy conversion wrapper\n=======================\n\nIn certain cases it may be more convenient to use an object that can be used\nboth as ``bytes`` or ``unicode`` as needed. The class ``StrMorpher`` is\nprovided for this case. Its constructor takes the same arguments as the\nconversion functions. The object makes calls to the appropriate conversion\nfunction when its \"magic\" methods that convert to ``bytes`` or ``unicode``\nare invoked.\n\nNote, that ``StrMorpher`` is not itself a subclass of any of the string\ntypes and relies on the \"magic\" methods being called to produce the actual\nstring objects.\n\nSee docstrings in the module for more detailed description of the class.\n\n\nDefault encoding\n================\n\nThe ``encoding`` parameter is optional in all places where it's accepted. Where\nit is left as ``None``, the default encoding is used.\n\nThe default encoding is controlled by ``default_encoding`` global\nvariable in the ``morphys`` module. Initially it's set to \"utf-8\", but it's\nallowed to set it to a different encoding name from user code.\n\n\nPython 3\n========\n\nWhile **Morphys** is mostly meant to solve issues of string types handling in\nPython 2, it's fully compatible with Python 3 and can be used with it.\n\n\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/mkalinski/morphys", "keywords": "string unicode bytes conversion", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "morphys", "package_url": "https://pypi.org/project/morphys/", "platform": "", "project_url": "https://pypi.org/project/morphys/", "project_urls": { "Homepage": "https://github.com/mkalinski/morphys" }, "release_url": "https://pypi.org/project/morphys/1.0/", "requires_dist": null, "requires_python": "", "summary": "Smart conversions between unicode and bytes types for common cases", "version": "1.0" }, "last_serial": 2565489, "releases": { "1.0": [ { "comment_text": "", "digests": { "md5": "1895a73507ad4c680a45c8f5cab24265", "sha256": "76d6dbaa4d65f597e59d332c81da786d83e4669387b9b2a750cfec74e7beec20" }, "downloads": -1, "filename": "morphys-1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "1895a73507ad4c680a45c8f5cab24265", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 5618, "upload_time": "2017-01-10T20:08:56", "url": "https://files.pythonhosted.org/packages/f9/4f/cb781d0ac5d079adabc77dc4f0bc99fc81c390029bd33c6e70552139e762/morphys-1.0-py2.py3-none-any.whl" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "1895a73507ad4c680a45c8f5cab24265", "sha256": "76d6dbaa4d65f597e59d332c81da786d83e4669387b9b2a750cfec74e7beec20" }, "downloads": -1, "filename": "morphys-1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "1895a73507ad4c680a45c8f5cab24265", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 5618, "upload_time": "2017-01-10T20:08:56", "url": "https://files.pythonhosted.org/packages/f9/4f/cb781d0ac5d079adabc77dc4f0bc99fc81c390029bd33c6e70552139e762/morphys-1.0-py2.py3-none-any.whl" } ] }