{ "info": { "author": "Esteban Castro Borsani", "author_email": "ecastroborsani@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Environment :: Web Environment", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 3", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "# emoji-unicode\n\n[![Build Status](https://img.shields.io/travis/nitely/emoji-unicode.svg?style=flat-square)](https://travis-ci.org/nitely/emoji-unicode)\n[![Coverage Status](https://img.shields.io/coveralls/nitely/emoji-unicode.svg?style=flat-square)](https://coveralls.io/r/nitely/emoji-unicode)\n[![pypi](https://img.shields.io/pypi/v/emoji-unicode.svg?style=flat-square)](https://pypi.python.org/pypi/emoji-unicode)\n[![licence](https://img.shields.io/pypi/l/emoji-unicode.svg?style=flat-square)](https://raw.githubusercontent.com/nitely/emoji-unicode/master/LICENSE)\n\nReplace unicode emojis in a text. Supports *Unicode 10* standard.\n\n## Compatibility\n\n* Python 2.7 ([wide-build](http://emoji-unicode.readthedocs.org/en/latest/python2.html)),\n3.3, 3.4, 3.5 and +3.6 (recommended)\n\n## Install\n\n```\n$ pip install emoji-unicode\n```\n\n## Usage\n\n### Replace\n\n[docs](http://emoji-unicode.readthedocs.org/en/latest/api.html#emoji_unicode.replace)\n\n```python\nemoji_unicode.replace(\n u'Time to \u26fd',\n lambda e: u'\"{raw}\"'.format(filename=e.code_points, raw=e.unicode)\n)\n# Time to \"\u26fd\"\n```\n\n> Note: the [Emoji.code_points](http://emoji-unicode.readthedocs.org/en/latest/api.html#emoji_unicode.Emoji.code_points) are normalized.\n\n### Normalize\n\nThis function removes optional characters that may appear depending on\nthe input source (Android, iOS, etc). For example the emoji variation `\\\\uFE0F`\nmay (or may not) appear in between a emoji and a skin tone modifier,\nmaking the code points to be different. It should be used\nto rename the image files.\n\n[docs](http://emoji-unicode.readthedocs.org/en/latest/api.html#emoji_unicode.normalize)\n\n```python\nemoji_unicode.normalize(u'1F468-200D-2764-FE0F-200D-1F468')\n# 1f468-2764-1f468\n```\n\n### Replace (advanced)\n\n```python\nPATTERN = re.compile(emoji_unicode.RE_PATTERN_TEMPLATE)\n\n\ndef match_handler(m):\n e = emoji_unicode.Emoji(unicode=m.group('emoji'))\n return u'\"{raw}\"'.format(\n filename=e.code_points,\n raw=e.unicode\n )\n\n\nre.sub(PATTERN, match_handler, u'Time to \u26fd')\n# Time to \"\u26fd\"\n```\n\n## Docs\n\n[docs](http://emoji-unicode.readthedocs.org/en/latest/)\n\n## Unicode 8 emojis\n\nIf your current emoji package supports unicode 8,\nwhich means it supports skin tones and [sequences](http://unicode.org/reports/tr51/),\nthen [normalizing](https://github.com/nitely/emoji-unicode#normalize) the file names\nshould be enough. But to handle unsupported emojis, for example future sequences,\nthey should be displayed as multiple glyphs.\n\nInstead of displaying the `woman-kissing-man` glyph you may\ndisplay `woman`, `heart`, `kiss`, `man` glyphs.\n\nHere is a example of how this could be handled:\n\n```python\nEMOJI_FILES = set(['1f469', '2764', '1f48b', '1f468']) # A set containing the emoji file names\n\n\ndef _render(unicode, code_points):\n return u'\"{alt}\"'.format(filename=code_points, alt=unicode)\n\n\ndef render(e):\n \"\"\"\n Return the rendered html for the passed Emoji.\n Return the html as multiple glyphs when the\n emoji is a sequence not found within the files.\n Return the raw unicode when one or more glyphs\n are missing.\n \"\"\"\n if e.code_points in EMOJI_FILES:\n return _render(e.unicode, e.code_points)\n\n if any(c not in EMOJI_FILES for u, c in e.as_map()):\n return e.unicode\n\n return u''.join(_render(u, c) for u, c in e.as_map())\n\n\n# This assumes `woman-kissing-man.svg` is missing\nemoji_unicode.replace(\n u'\\U0001f469\\u200d\\u2764\\ufe0f\\u200d\\U0001f48b\\u200d\\U0001f468',\n render\n)\n# \"\\U0001f469\"\"\\u2764\" ...\n```\n\n## Dev\n\nThe `./emoji_unicode/pattern.py` file is generated\nby parsing the `./emoji_unicode/emoji-data.txt` file,\nthen putting the output in a in-memory copy of\n`./emoji_unicode/pattern_template.py`, and lastly\nwriting the result into `pattern.py`.\n\nTo generate the `pattern.py` file, run:\n\n```\nmake gen\n```\n\n## Tests\n\n```\nmake test\n```\n\n## Benchmark\n\nThis will run some silly benchmarks.\n\n```\nmake bench\n```\n\nHere is the output on my machine:\n\n```\nemoji.replace()\ntext len: 10000\n0.01640868396498263\n\nre.sub() (raw match)\ntext len: 10000\n0.005225047003477812\n\nText with no emojis\nemoji.replace()\ntext len: 10000\n0.0014624089817516506\n```\n\n## Acknowledgments\n\nThanks to [iamcal/emoji-data](https://github.com/iamcal/emoji-data)\nfor maintaining an incredible source of emojis that allowed me\nto make a robust test suite.\n\n## License\nMIT\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/nitely/emoji-unicode", "keywords": "", "license": "MIT License", "maintainer": "", "maintainer_email": "", "name": "emoji-unicode", "package_url": "https://pypi.org/project/emoji-unicode/", "platform": "", "project_url": "https://pypi.org/project/emoji-unicode/", "project_urls": { "Homepage": "http://github.com/nitely/emoji-unicode" }, "release_url": "https://pypi.org/project/emoji-unicode/0.4/", "requires_dist": null, "requires_python": "", "summary": "Replace unicode emojis by its corresponding image representation. Supports Unicode 9 standard.", "version": "0.4" }, "last_serial": 3240548, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "76dca358ab4cbfd6c63ff6a59dd93696", "sha256": "17e8e315ab002c926dfbf6b7161992b6fdb7721d19556dbe8c6538f5e535e552" }, "downloads": -1, "filename": "emoji-unicode-0.1.tar.gz", "has_sig": false, "md5_digest": "76dca358ab4cbfd6c63ff6a59dd93696", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 84090, "upload_time": "2015-11-18T22:04:41", "url": "https://files.pythonhosted.org/packages/32/ba/3162c791442556f0c22642a8582f6ef68b65e0af72a3bbdaf6cd909fd95c/emoji-unicode-0.1.tar.gz" } ], "0.2": [ { "comment_text": "", "digests": { "md5": "7bcbfbbb96710022a59903cefdb7d8c6", "sha256": "1243ed4bb230e1d3cde32f929114d97544ed41e6ca95c6a41b6c6288a5d957ae" }, "downloads": -1, "filename": "emoji-unicode-0.2.tar.gz", "has_sig": false, "md5_digest": "7bcbfbbb96710022a59903cefdb7d8c6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 85232, "upload_time": "2015-11-19T15:22:45", "url": "https://files.pythonhosted.org/packages/89/5b/9c29fbfd28da6f0dcd1b18e86b9a1c323e8f91117b68bf2908cb3290c450/emoji-unicode-0.2.tar.gz" } ], "0.4": [ { "comment_text": "", "digests": { "md5": "7a109399946669a6b6f5f559826632b1", "sha256": "046d4b18093adaae2311d5323dc5910159e3e9233dd262287a14284607dde92c" }, "downloads": -1, "filename": "emoji-unicode-0.4.tar.gz", "has_sig": false, "md5_digest": "7a109399946669a6b6f5f559826632b1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 24602, "upload_time": "2017-10-10T21:07:36", "url": "https://files.pythonhosted.org/packages/f2/2d/2eeac58c543477454cf15ba62c5df38d73ef49acc05ef0ccd4ab545605e3/emoji-unicode-0.4.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "7a109399946669a6b6f5f559826632b1", "sha256": "046d4b18093adaae2311d5323dc5910159e3e9233dd262287a14284607dde92c" }, "downloads": -1, "filename": "emoji-unicode-0.4.tar.gz", "has_sig": false, "md5_digest": "7a109399946669a6b6f5f559826632b1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 24602, "upload_time": "2017-10-10T21:07:36", "url": "https://files.pythonhosted.org/packages/f2/2d/2eeac58c543477454cf15ba62c5df38d73ef49acc05ef0ccd4ab545605e3/emoji-unicode-0.4.tar.gz" } ] }