{ "info": { "author": "j1bz", "author_email": "jbaptiste.braun@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Natural Language :: French", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.0", "Programming Language :: Python :: 3.1", "Programming Language :: Python :: 3.2", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: Implementation :: CPython", "Topic :: Software Development", "Topic :: Utilities" ], "description": "Summary\n=======\n\n* `Description`_\n\n * `Crudity expressions, cool ! But... what is it ?`_\n\n* `Installation`_\n* `How-to`_\n\n * `Quickstart`_\n * `Examples of expressions`_ \n\n * `CREATE`_\n * `READ`_\n * `UPDATE`_\n * `DELETE`_\n\n* `Advanced how-to`_\n\n * `Using a custom grammar`_\n * `Interpreter vs interpret`_\n * `Exception handling`_\n\nDescription\n===========\n\nExpression is a Domain Specific Language (DSL) designed to express CRUD queries\nfor ``b3j0f.crudity`` (https://github.com/b3j0f/requester/).\n\nIn other words, you can write Crudity Expressions.\n\nCrudity expressions, cool ! But... what is it ?\n-----------------------------------------------\n\nThis package has been designed to work in strong coupling with\n``b3j0f.requester``, so you should know what it is before continuing.\n\nIn ``b3j0f.requester``, everything is an ``Expression`` (``E``) or a\n``Function`` (``F``). If you want to compare ``a`` and ``b`` you need to write\n:\n\n.. code-block:: python\n\n >>> F('>', params=[E.a, E.b])\n\nA programmer can manipulate those nested function calls with no problem, but\npeople with less technical background will find difficulties doing it.\n``j1bz.expression`` aims to make ``b3j0f.requester`` calls more accessible. The\nsyntax is highly inspired from SQL, because any IT guy should have seen at\nleast a few SQL queries and should not be lost :\n\n.. code-block:: python\n\n >>> interpret(\"SELECT ALL WHERE (a > b);\")\n\nThe syntax is more restrictive than what native ``b3j0f.requester`` allows you\nto do (main needs are covered). Thus, users are incentived to write things that\nmake sense.\n\n``j1bz.expression.intepreter.interpret`` return a\n``b3j0f.requester.request.crud.{create.Create,read.Read,update.Update,delete.Delete}``\nserialized object (depending on the query). The object can then be processed by\nany driver.\n\nInstallation\n============\n\n.. code-block:: bash\n\n aptitude install git virtualenv\n\n virtualenv venv\n source venv/bin/activate\n\n git clone https://github.com/b3j0f/requester\n\n cd requester\n python setup.py install\n\n pip install j1bz.expression\n\n expression-cli\n\nHow-to\n======\n\nQuickstart\n----------\n\n.. code-block:: python\n\n >>> from j1bz.expression.interpreter import interpret\n >>> res = interpret(\"SELECT a;\")\n >>> print(repr(res))\n SELECT a\n\n**Note**: ``j1bz.expression.exceptions.ParseError`` should be the only\nexception you have to catch when invoking interpret function as is.\n\nExamples of expressions\n-----------------------\n\nCREATE\n~~~~~~\n\n.. code-block:: bash\n\n INSERT VALUES k:v;\n INSERT VALUES k1:v1, k2:v2;\n INSERT INTO i VALUES k:v;\n INSERT VALUES k:v; AS i\n\n**Note**: ``CREATE`` is a synonym of ``INSERT``. It means every time you can\nuse ``INSERT`` you could have used ``CREATE`` instead (for semantics in some\ncases).\n\n.. code-block:: bash\n\n CREATE VALUES k:v;\n\nREAD\n~~~~\n\n.. code-block:: bash\n\n SELECT ALL;\n SELECT s;\n SELECT s WHERE w;\n SELECT s GROUP BY g;\n SELECT s ORDER BY o;\n SELECT s LIMIT 10;\n SELECT s; AS mys\n\n SELECT s WHERE wh GROUP BY g ORDER BY o LIMIT 10; AS mys\n\n SELECT a, b, c;\n SELECT f();\n SELECT f(a, b, c);\n\n SELECT s WHERE (a);\n SELECT s WHERE (a = b);\n SELECT s WHERE (a != b);\n SELECT s WHERE (a > b);\n SELECT s WHERE (a >= b);\n SELECT s WHERE (a < b);\n SELECT s WHERE (a <= b);\n SELECT s WHERE (a IN b);\n SELECT s WHERE (a NIN b);\n SELECT s WHERE (a LIKE b);\n\n SELECT s WHERE (a AND b);\n SELECT s WHERE (a OR b);\n SELECT s WHERE (a OR (b AND c));\n\n SELECT s ORDER BY o1, o2;\n SELECT s ORDER BY o1 DESC, o2, o3 ASC;\n\n**Note**: ``READ`` is a synonym of ``SELECT``.\n\n.. code-block:: bash\n\n READ ALL;\n\nUPDATE\n~~~~~~\n\n.. code-block:: bash\n\n UPDATE VALUES k:v;\n UPDATE VALUES k:v WHERE w;\n UPDATE VALUES k:v; AS myu\n\n UPDATE INTO u VALUES k:v;\n UPDATE INTO u VALUES k:v WHERE w;\n UPDATE INTO u VALUES k1:v1, k2:v2;\n\nDELETE\n~~~~~~\n\n.. code-block:: bash\n\n DELETE d;\n DELETE d1, d2, d3;\n DELETE d WHERE w;\n DELETE d1, d2, d3 WHERE w;\n DELETE d; AS myd\n\n**Note**: Expression uses Grako (https://pypi.python.org/pypi/grako) to\ngenerate a parser from a grammar defined in\n``{{ PACKAGE }}/etc/j1bz/expression/grammar.bnf``. You can read this bnf\ndescription to check for all available possibilities.\n\nAdvanced how-to\n---------------\n\nIf you want to integrate ``j1bz.expression`` in your code to do more than just\n``interpret()`` calls, this part is for you.\n\nUsing a custom grammar\n~~~~~~~~~~~~~~~~~~~~~~\n\nThe engine powering ``j1bz.expression`` is ``grako``. Grako (for Grammar\nKompiler) take a bnf-derivated grammar file in input and generates a parser in\npython code.\n\nThis package embeds a grammar file and a pre-compiled parser generated from\nthis grammar (``{{ PACKAGE }}/etc/j1bz/expression/grammar.bnf``).\n\nIt is possible to change this grammar and use a parser generated at runtime for\nyour ``interpret()`` calls :\n\n.. code-block:: python\n\n >>> interpret(\"SELECT a;\", \"/PATH/TO/grammar.bnf\")\n\n**Note**: Once you've called ``interpret()`` for the first time (with or\nwithout grammar file), the same parser used for the first time will be used\nlater (due to a singleton mechanic). \n\nInterpreter vs interpret\n~~~~~~~~~~~~~~~~~~~~~~~~\n\n``interpret()`` uses a singleton mechanic to provide a shortcut.\n\nIf you want to do more complex things, you can use the\n``j1bz.expression.interpreter.Interpreter`` class.\n\nExamples :\n\n.. code-block:: python\n\n >>> i1 = Interpreter(parser=mygrakoparser, walker=mycustomwalker)\n >>> i1.interpret(\"SELECT a;\")\n\n >>> i2 = Interpreter(pkwargs={'rule_name': 'condition'})\n >>> i2.interpret(\"(a > b)\")\n\n >>> i3 = Interpreter(grammar_file='/PATH/TO/grammar.bnf')\n >>> i3.interpret(\"SELECT_ALIAS a;\")\n\n**Note**: ``grammar_file`` argument will be used only if you did not provide a\ncustom parser via ``parser`` argument.\n\nException handling\n~~~~~~~~~~~~~~~~~~\n\n``j1bz.expression.exceptions`` currently defines 2 exceptions :\n\n- ``ParserGenerationError`` : Raised when you provide a custom grammar in\n order to generate a parser, but generation failed (your grammar is not\n correct !).\n- ``ParseError`` : Raised when an expression given to ``interpret()`` is not\n parsable.\n\nSome other exceptions (``IOError``, ``OSError``, ``FileNotFoundError``) can\nalso be raised when trying to compile a custom parser if the grammar file is\nnot readable, does not exist, etc.\n\nIf you're only using ``interpret()`` shortcut, you should handle all named\nexceptions above.\n\nIf you're using ``Interpreter`` class, you need to handle\n``ParserGenerationError`` (and file related exceptions) when you instantiate it\nand ``ParseError`` when you make ``interpret()`` calls.", "description_content_type": null, "docs_url": null, "download_url": "https://github.com/j1bz/expression/tarball/0.0.4", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/j1bz/expression", "keywords": "expression,crudity,dsl,query,system,access,data,crud,create,delete,update,read,request,grako", "license": "MIT License", "maintainer": null, "maintainer_email": null, "name": "j1bz.expression", "package_url": "https://pypi.org/project/j1bz.expression/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/j1bz.expression/", "project_urls": { "Download": "https://github.com/j1bz/expression/tarball/0.0.4", "Homepage": "https://github.com/j1bz/expression" }, "release_url": "https://pypi.org/project/j1bz.expression/0.0.4/", "requires_dist": null, "requires_python": null, "summary": "DSL intended to express requests for b3j0f.crudity.", "version": "0.0.4" }, "last_serial": 2410823, "releases": { "0.0.3": [ { "comment_text": "", "digests": { "md5": "522c9b7ee1c951139ca761f12c492464", "sha256": "c926d2a98c26b5b160eb8036eea63d277000dcfd31ef9ec61229816e6cca5510" }, "downloads": -1, "filename": "j1bz.expression-0.0.3.tar.gz", "has_sig": false, "md5_digest": "522c9b7ee1c951139ca761f12c492464", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10338, "upload_time": "2016-10-17T15:39:01", "url": "https://files.pythonhosted.org/packages/b4/dc/130e1f550bffc2e9cdba67234bf6cd9c92bb93581ad5c4e53c776cfb5987/j1bz.expression-0.0.3.tar.gz" } ], "0.0.4": [ { "comment_text": "", "digests": { "md5": "c28342487914152c3b66112c4e496b05", "sha256": "b5ab554b7f577e4ba7672a2f5959b21207f86ed40e128b419c44839630618adc" }, "downloads": -1, "filename": "j1bz.expression-0.0.4.tar.gz", "has_sig": false, "md5_digest": "c28342487914152c3b66112c4e496b05", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13091, "upload_time": "2016-10-18T12:17:01", "url": "https://files.pythonhosted.org/packages/be/44/3d80bfc9d644d3f905b4239c22a6e005884422742d0122fdd2037ca1c22a/j1bz.expression-0.0.4.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "c28342487914152c3b66112c4e496b05", "sha256": "b5ab554b7f577e4ba7672a2f5959b21207f86ed40e128b419c44839630618adc" }, "downloads": -1, "filename": "j1bz.expression-0.0.4.tar.gz", "has_sig": false, "md5_digest": "c28342487914152c3b66112c4e496b05", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13091, "upload_time": "2016-10-18T12:17:01", "url": "https://files.pythonhosted.org/packages/be/44/3d80bfc9d644d3f905b4239c22a6e005884422742d0122fdd2037ca1c22a/j1bz.expression-0.0.4.tar.gz" } ] }