{ "info": { "author": "Andrew Udvare", "author_email": "audvare@gmail.com", "bugtrack_url": null, "classifiers": [], "description": ".. image:: https://travis-ci.org/Appdynamics/python-langutil.png?branch=develop :target: https://travis-ci.org/Appdynamics/python-langutil\n\nLanguage Utility\n================\n\nCurrently, this utility only outputs equivalent PHP code.\n\nPHP\n---\n\n.. code:: python\n\n import langutil.php\n\nConverting 'scalars'\n~~~~~~~~~~~~~~~~~~~~\n\nA scalar in PHP is anything that is not an object (in PHP:\n``!is_object(1) === true``).\n\n.. code:: python\n\n # Booleans\n langutil.php.generate_scalar(True) == 'true'\n langutil.php.generate_scalar(True, True) == 'TRUE'\n\n # None turns into null\n langutil.php.generate_scalar(None) == 'null'\n langutil.php.generate_scalar(None, True) == 'null'\n\n # Numbers are untouched\n langutil.php.generate_scalar(1) == '1'\n langutil.php.generate_scalar(2.5) == '2.5'\n\n # Strings use single quotes unless it is necessary to use double quotes\n # Double quotes are only necessary if the character has any control codes\n langutil.php.generate_scalar('php code!') == ''php code!''\n langutil.php.generate_scalar('this string has\\nnew lines') == '\"this string has\\nnew lines\"'\n\nConverting lists, tuples, dictionaries, etc\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nThese types all resolve to the same type in PHP: the 'PHP array'. The\n``generate_array()`` function handles recursive structures but may fail\nto detect special objects' underlying structure unless they implement\nmethods like ``__dict__()``.\n\nAll strings (including keys for dictionaries) will default to single\nquotes unless double quotes are necessary.\n\nThe output will use new lines and two-space indents.\n\n.. code:: python\n\n langutil.php.generate_array([]) == 'array();'\n langutil.php.generate_array(tuple([])) == 'array();'\n langutil.php.generate_array(set(tuple([]))) == 'array();'\n langutil.php.generate_array({}) == 'array();'\n\nList/set/tuple conversion\n^^^^^^^^^^^^^^^^^^^^^^^^^\n\n.. code:: python\n\n langutil.php.generate_array([\n 1,\n 2,\n ])\n\nOutput:\n\n.. code:: php\n\n array(\n 1,\n 2,\n );\n\nDictionary conversion\n^^^^^^^^^^^^^^^^^^^^^\n\nFor dictionaries, order of keys is not guaranteed. In PHP, hashes are\nordered.\n\n.. code:: python\n\n langutil.php.generate_array({\n 'special': '\\n',\n 'special\\x05': 'a string',\n 'key': 1,\n 'list': [1,2,3],\n })\n\nOutput:\n\n.. code:: php\n\n array(\n 'key' => 1,\n 'list' => array(\n 1,\n 2,\n 3,\n ),\n \"special\\x05\" => 'a string',\n 'special' => \"\\n\",\n );\n\nSerialisation\n~~~~~~~~~~~~~\n\nUse ``php.serialize(data_arg)`` for serialising data in PHP's special\nserialisation format. The module will try to use the module\n``phpserialize`` for this first but has a fallback version in pure\nPython for simple values (does not handle 'classes', references, or\n'objects').\n\nNote that the types ``list``, ``tuple``, ``set``, and ``dict`` become\nPHP arrays (the serialisation format requires 'keys' to be created for\nlists so these become integers but should be an equivalent\n'integer-based array' in PHP (the number keys do *not* become string\nkeys).\n\nTo unserialize, use ``php.unserialize(str_arg)`` which requires the\n``phpserialize`` module.\n\n.. |Build Status| image:: https://travis-ci.org/Appdynamics/python-langutil.png?branch=develop\n :target: https://travis-ci.org/Appdynamics/python-langutil", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://pypi.python.org/pypi/LangUtil/", "keywords": null, "license": "LICENSE.txt", "maintainer": null, "maintainer_email": null, "name": "LangUtil", "package_url": "https://pypi.org/project/LangUtil/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/LangUtil/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://pypi.python.org/pypi/LangUtil/" }, "release_url": "https://pypi.org/project/LangUtil/0.1.5/", "requires_dist": null, "requires_python": null, "summary": "Helpers for generating code.", "version": "0.1.5" }, "last_serial": 1125165, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "3a36b3e11ef5842ce306b3b28d69ac5f", "sha256": "6463bdbbba37504ac8d5b587360707e3ea3c0e6be6db43fb8cd6b4819f9291cc" }, "downloads": -1, "filename": "LangUtil-0.1.0.tar.gz", "has_sig": false, "md5_digest": "3a36b3e11ef5842ce306b3b28d69ac5f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2273, "upload_time": "2013-11-14T23:50:21", "url": "https://files.pythonhosted.org/packages/ab/7a/fad1cbb5d0708220293158d77023f755e3d7235541d3eb75a6ea37f02603/LangUtil-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "9e88fe0d37a98038852b636d51476217", "sha256": "191961680cff2ab38413c77d990e3a44ab60bd7f3d5fb674f5c7f5b96f9b40ce" }, "downloads": -1, "filename": "LangUtil-0.1.1.tar.gz", "has_sig": false, "md5_digest": "9e88fe0d37a98038852b636d51476217", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3083, "upload_time": "2013-11-29T02:57:25", "url": "https://files.pythonhosted.org/packages/60/e4/aa016814ab9784b2755ddabc2204ebab1919348e3dd1a984a53dc14a36a1/LangUtil-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "ec537335c096eaa44059c0797a6a1bdc", "sha256": "1bab62314ce6a71cb470142201b7d26566eb036c696d0c7c7735382f8429d42f" }, "downloads": -1, "filename": "LangUtil-0.1.2.tar.gz", "has_sig": false, "md5_digest": "ec537335c096eaa44059c0797a6a1bdc", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3348, "upload_time": "2013-11-29T04:40:40", "url": "https://files.pythonhosted.org/packages/d2/7f/c0a1f2c5f0feb81bb17bf94c9193a78d7216d681b4c25e13c919a2f60b25/LangUtil-0.1.2.tar.gz" } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "c3152e4fb574fded3d2ce306f5ec86a2", "sha256": "e0cb4898c7d197144e7f7e86cf985979b6d14626dcdf795a80e0b3c436445726" }, "downloads": -1, "filename": "LangUtil-0.1.3.tar.gz", "has_sig": false, "md5_digest": "c3152e4fb574fded3d2ce306f5ec86a2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3685, "upload_time": "2013-12-23T00:22:16", "url": "https://files.pythonhosted.org/packages/33/37/10392be392a45eeb9a824e5ecab6815d83a92eb9ee043c9c2d23889787a2/LangUtil-0.1.3.tar.gz" } ], "0.1.4": [ { "comment_text": "", "digests": { "md5": "00263f124670c2f997358f6eaf58a5d3", "sha256": "9681524c164e3078ec3337c122e2b38e462566373c51eea2464630639d4dffd5" }, "downloads": -1, "filename": "LangUtil-0.1.4.tar.gz", "has_sig": false, "md5_digest": "00263f124670c2f997358f6eaf58a5d3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4261, "upload_time": "2013-12-30T22:20:26", "url": "https://files.pythonhosted.org/packages/d3/26/0669577ba029954230e2bb98f778d8cb8e48230246428a464c1ca0b339d3/LangUtil-0.1.4.tar.gz" } ], "0.1.5": [ { "comment_text": "", "digests": { "md5": "eb6e9b835976ba387e99df3fa6089e29", "sha256": "d1506088062b0055cfa0c1501dfff0f256d27591b25899cc90f7dbd448e2d9d1" }, "downloads": -1, "filename": "LangUtil-0.1.5.tar.gz", "has_sig": false, "md5_digest": "eb6e9b835976ba387e99df3fa6089e29", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4422, "upload_time": "2014-06-15T04:18:03", "url": "https://files.pythonhosted.org/packages/c2/ef/1a7e9476ea74235d9ff5842a4e43f5dc666cc8130e7cf323895b52c5cd5c/LangUtil-0.1.5.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "eb6e9b835976ba387e99df3fa6089e29", "sha256": "d1506088062b0055cfa0c1501dfff0f256d27591b25899cc90f7dbd448e2d9d1" }, "downloads": -1, "filename": "LangUtil-0.1.5.tar.gz", "has_sig": false, "md5_digest": "eb6e9b835976ba387e99df3fa6089e29", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4422, "upload_time": "2014-06-15T04:18:03", "url": "https://files.pythonhosted.org/packages/c2/ef/1a7e9476ea74235d9ff5842a4e43f5dc666cc8130e7cf323895b52c5cd5c/LangUtil-0.1.5.tar.gz" } ] }