{ "info": { "author": "F\u00e1bio Mac\u00eado Mendes", "author_email": "fabiomacedomendes@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: GNU General Public License (GPL)", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Topic :: Software Development :: Libraries" ], "description": ".. image:: https://travis-ci.org/Transpyler/transpyler.svg?branch=master\n :target: https://travis-ci.org/Transpyler/transpyler\n\n.. image:: https://codecov.io/gh/Transpyler/transpyler/branch/master/graph/badge.svg\n :target: https://codecov.io/gh/Transpyler/transpyler\n\n.. image:: https://ci.appveyor.com/api/projects/status/it45pshyqi76irbx?svg=true\n :target: https://ci.appveyor.com/project/fabiommendes/transpyler\n\n\nTranspyler is an infrastructure to create simple localized versions of\nPython. It was originally created as part of the Pytugu\u00eas language (Python\nin Portuguese), but it is now abstracted to handle any translation. The\ngoal of such specialized languages is to provide a more friendly environment to\nnewcomers that are not fluent in English, children and adults alike.\n\nCreating support for a new language is very simple. Say we want to create a\nPy-Klingon to help us dominate the galaxy. Fortunately, Klingon structure is\nnot very different from English and we can go a long way just by translating\ntokens. In transpyler it looks like this:\n\n.. code-block:: python\n\n from transpyler import Transpyler\n\n # Let us define Py-Klingon\n klingon = Transpyler(\n name='Py-Klingon',\n translations={\n # Warning: computer-based translation!\n 'meH': 'for',\n 'chugh': 'if',\n 'latlh': 'else',\n 'Qap': 'def',\n 'nobHa': 'return',\n # ... you get the idea ;-)\n })\n\n\n # Now execute some Klingon number crunching\n klingon.exec('''\n Qap fib(x):\n chugh x < 0:\n nobHa 1\n latlh:\n nobHa fib(x - 1) + fib(x - 2)\n ''', globals())\n\n print(fib(10)) # It creates a Python function!\n\n\nSince the main goal is educational, transpyler-enabled languages automatically\nsupports a series of nice educational tools inherited from the original Pytugu\u00eas\nruntume:\n\n* Support for Jupyter/IPython: we can easily create a Jupyter kernel from a\n Transpyler instance. This enables nice consoles and notebooks which\n can be really handy in teaching a new programming language.\n* QCode support and syntax highlight: QCode is a Qt-based widget for coding\n editing.\n* Pygments plugin: Pygments is a source code highlighter commonly used to generate\n nice coloured HTML for source code.\n* QTurtle application: QTurtle is similar to Python's own turtle module rewritten\n in Qt. This is great for teaching kids, and all transpyled languages support\n it for free :)\n\n\nHow does it work?\n-----------------\n\nTranspilation is the act of translating code from one programming language to\nanother (as opposed to compilation, which translate source code to machine\ncode). A **transpylation** is even simpler: it translate a Python-like language\nback to Python (and sometimes execute it directly). This task is not very\ndifficult since both languages are similar and we can reuse lots of Python's\nown machinery to analyze and modify its own source code.\n\nTranspyler acts exclusively at the token level: it modifies the stream of tokens\nfrom the original translated language to a new stream of tokens that must then\ngenerate a grammatically valid python program. Indeed, we do not even implement\nour own tokenizer and use Python's own ``tokenize`` module to handle this part\nfor us.\n\nTranspyler works by making several passes over the list of tokens. The first\npass simply performs direct translations such as those shown in the Py-Klingon\nexample above. A second pass makes maps groups of tokens into a single Python\ntoken (eg.: we could make a \"for each\" command that is translated to \"for\").\n\nSubsequent passes may look for specific patterns of tokens and perform more\ncomplex translations. Pytugu\u00eas, for instance, implements a \"repeat\" command.\nIn English it would be something like this:\n\n\n.. code-block:: transpyler\n\n repeat 4 times:\n forward(100)\n left(90)\n\nThis is transpiled to Python as:\n\n.. ignore-next-block\n.. code-block:: python\n\n for ___ in range(4):\n forward(100)\n left(90)\n\nIt is possible to make arbitrary modifications to the list of tokens which in\nprinciple could allow arbitrary syntactic constructs. Notice that tokens still\ncome from the Python tokenizer and hence there are certain hard lexical\nconstraints on (including indentation as block delimiter semantics which in\nPython is implemented at the tokenizer level rather than in the grammar).\n\nTranspyler do not implement source code maps because they are not needed by\nPytugu\u00eas and we don't think that simple localized Pythons would require\nit. That said, new grammatical constructs should keep line numbers unaltered.\n\nRemember: transpyler is using your regular vanilla Python interpreter and putting\na small layer of token translation on top of it. We make a few dirty hacks in the\nPython runtime, but it does not requires any specially flavored interpreter\nand additional compilation is unnecessary.\n\n\nAnd the standard lib?\n---------------------\n\nI'm glad you asked :). This is by far the most laborious part of doing a decent\nPython translation. Transpyler offers a few helpful tools, but most of the work\nis the inevitable task of translating the names and docstrings of each function\nyou want to support into a their localized counterparts.\n\nAs a convenience tool, you can list the functions you want to translate and\nwe offer a tool that uses Google Translate to create a boilerplate for your\nstandard lib functions. Google Translate is a wonderful tool, but we all know\nhow bad it can get for serious translations. Always keep that in mind.\n\nHere is a list of all projects using Transpyler.\n\n* Pytugu\u00eas: the original Python to portuguese.\n* Pykor: Korean version.\n* Pytu\u00f1ol: non-serious translation to Portu\u00f1ol. It is a minimal project and can\nbe used as a template for new translations.\n\n\nHow about the builtin types?\n----------------------------\n\nPython builtins poses a challenge. They cannot be monkey-patched at Python level,\nbut we need to modify them. In Py-Klingon, we want the \"teH\" constant (True) to\nbe represented as \"teH\" rather than \"True\". We also want method names for\nlists, strings, etc to be fully translated.\n\nTranspyler messes with these types at C level using ctypes. The techniques are\nvery similar to those implemented in a module called ``forbiddenfruit``,\nwhich recommends never to use itself unless you want to do something dangerous or\nsilly :)\n\nIn the language introduced by ``forbiddenfruit``, modifying a method to a builtin\ntype is called making a curse. We provide a tools to curse Python's builtins easily\nand effectively.\n\n\nA superset of Python?\n---------------------\n\nTranspyler languages are usually supersets of Python itself. In Pytugu\u00eas, for\ninstance, most Python code is also a valid Pytugu\u00eas code. This makes languages\neasier to implement since we don't have to blacklist the original Python\nkeywords, but it also creates a path for going from a educational Pythonesque\nlanguages to vanilla Python used in real world applications.\n\nThe fact that we don't make any effort to hide the Python internals and Python\noriginal syntax is not a bug, its a feature!\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/transpyler/transpyler/", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "transpyler", "package_url": "https://pypi.org/project/transpyler/", "platform": "any", "project_url": "https://pypi.org/project/transpyler/", "project_urls": { "Homepage": "https://github.com/transpyler/transpyler/" }, "release_url": "https://pypi.org/project/transpyler/0.5.0/", "requires_dist": null, "requires_python": "", "summary": "A framework for building localized Python-like languages.", "version": "0.5.0" }, "last_serial": 4183295, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "5db321459ae50b4d3d9852f279154c35", "sha256": "6e8f82a40409cf76817577b52e746d3dad142b88c061f86f0ad4f848542211cf" }, "downloads": -1, "filename": "transpyler-0.1.0.tar.gz", "has_sig": false, "md5_digest": "5db321459ae50b4d3d9852f279154c35", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 20124, "upload_time": "2017-03-28T07:37:26", "url": "https://files.pythonhosted.org/packages/c6/93/206ab825b266bd152dbdd22497dfcfb4a022bc343c6df2e83d7b46a4a30e/transpyler-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "5f679d018500122b0a08d2a340c2c753", "sha256": "ad58f044ddf68926e6c98a4315423564a5fe752524062be6aad15ebea1957279" }, "downloads": -1, "filename": "transpyler-0.1.1.tar.gz", "has_sig": false, "md5_digest": "5f679d018500122b0a08d2a340c2c753", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 27499, "upload_time": "2017-04-02T17:54:22", "url": "https://files.pythonhosted.org/packages/40/8b/9df479f3064eff44638d03e44e07512ea952111a8377014079056e611e98/transpyler-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "ac68d450ba025963a2e273eb4d809866", "sha256": "e9c65588ff16815dc0a116bce089c9efc4e1f6333949c4698674dcaaa7211fe9" }, "downloads": -1, "filename": "transpyler-0.1.2.tar.gz", "has_sig": false, "md5_digest": "ac68d450ba025963a2e273eb4d809866", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 27936, "upload_time": "2017-04-02T21:18:17", "url": "https://files.pythonhosted.org/packages/be/6a/1247276ba7a6ac53d9491859bf18c810ece3f21f9356129baccf9c9c82b2/transpyler-0.1.2.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "e5d94a1b872293a2590e2c8b938ee134", "sha256": "8258190693ebdb1e0a3b9d3c37c0e5a12dc076b55ad832c6bdd4871eb989acff" }, "downloads": -1, "filename": "transpyler-0.2.0.tar.gz", "has_sig": false, "md5_digest": "e5d94a1b872293a2590e2c8b938ee134", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 61235, "upload_time": "2017-05-16T05:25:54", "url": "https://files.pythonhosted.org/packages/74/6b/d614e8ba925ac652195d0eb3fb3294a1bf1f456bd12d5a9af7b45c9bac62/transpyler-0.2.0.tar.gz" } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "de489f5b4f46307c90f8d3d673e7d2c0", "sha256": "e9cd4555624ed9f0561d58ad35b8bf3053ca03e9fa4979df4d48744383890c33" }, "downloads": -1, "filename": "transpyler-0.3.0.tar.gz", "has_sig": false, "md5_digest": "de489f5b4f46307c90f8d3d673e7d2c0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 105203, "upload_time": "2017-05-22T14:34:50", "url": "https://files.pythonhosted.org/packages/82/71/fbf39575c3427db8627a25525c6884af59f2bb8f83f00e3e414eddc53111/transpyler-0.3.0.tar.gz" } ], "0.3.1": [ { "comment_text": "", "digests": { "md5": "13f39179ab8904c1b861606f45ba7ace", "sha256": "781db72d80328eace34b61325dd964064d2fba80db5b89a57e433e40ee2ac03f" }, "downloads": -1, "filename": "transpyler-0.3.1.tar.gz", "has_sig": false, "md5_digest": "13f39179ab8904c1b861606f45ba7ace", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 105196, "upload_time": "2017-05-22T15:33:12", "url": "https://files.pythonhosted.org/packages/a8/11/abadea7b0a2dc23167818d41dec3709b8fd64e382e18e6d2780d4408ec3c/transpyler-0.3.1.tar.gz" } ], "0.4.0": [ { "comment_text": "", "digests": { "md5": "ab9918d041ef96d477a6d2fce0238db2", "sha256": "3051c81e3cb94eca1003b989f44faf07efadef6649dbec8544f2f5c03a474fce" }, "downloads": -1, "filename": "transpyler-0.4.0.tar.gz", "has_sig": false, "md5_digest": "ab9918d041ef96d477a6d2fce0238db2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 107865, "upload_time": "2017-09-15T14:37:27", "url": "https://files.pythonhosted.org/packages/47/99/9e809daa54ebef943a27ea205fee86bf0b42a9e5ee2a728dd28b8c9f249a/transpyler-0.4.0.tar.gz" } ], "0.4.1": [ { "comment_text": "", "digests": { "md5": "00dc215694ba55eeb309478ce75cf7bc", "sha256": "cc6c0eed342b04d6d4dc32d6bc50066de71b701bbe5409aa870d5e05a809aa7d" }, "downloads": -1, "filename": "transpyler-0.4.1.tar.gz", "has_sig": false, "md5_digest": "00dc215694ba55eeb309478ce75cf7bc", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 114826, "upload_time": "2017-09-15T22:17:09", "url": "https://files.pythonhosted.org/packages/bc/8c/87e81a8a5e6eedec17ba74e0a2e7807c9b9257564f2ee2f94ed558950bd9/transpyler-0.4.1.tar.gz" } ], "0.5.0": [ { "comment_text": "", "digests": { "md5": "9b929626bafe49a50f03e9b863682100", "sha256": "ad9a6e5e5053e6969cfca028b1d22effd52040b7489c3197913c6b192d638467" }, "downloads": -1, "filename": "transpyler-0.5.0.tar.gz", "has_sig": false, "md5_digest": "9b929626bafe49a50f03e9b863682100", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 109184, "upload_time": "2018-08-18T14:54:30", "url": "https://files.pythonhosted.org/packages/c7/bc/b295bf395ee4acd2093f2658f6907be5eb3071c4729cbafb44967f0a6b53/transpyler-0.5.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "9b929626bafe49a50f03e9b863682100", "sha256": "ad9a6e5e5053e6969cfca028b1d22effd52040b7489c3197913c6b192d638467" }, "downloads": -1, "filename": "transpyler-0.5.0.tar.gz", "has_sig": false, "md5_digest": "9b929626bafe49a50f03e9b863682100", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 109184, "upload_time": "2018-08-18T14:54:30", "url": "https://files.pythonhosted.org/packages/c7/bc/b295bf395ee4acd2093f2658f6907be5eb3071c4729cbafb44967f0a6b53/transpyler-0.5.0.tar.gz" } ] }