{ "info": { "author": "Arne K\u00fcderle", "author_email": "a.kuederle@gmail.com", "bugtrack_url": null, "classifiers": [ "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5" ], "description": "funcmap\n=======\n\n.. image:: https://img.shields.io/pypi/v/funcmap.svg\n :target: https://pypi.python.org/pypi/funcmap\n :alt: Latest PyPI version\n\n.. image:: https://img.shields.io/travis/AKuederle/funcmap.png\n :target: 'https://travis-ci.org/AKuederle/funcmap'\n :alt: Latest Travis CI build status\n\nA small Python module to provide convenient mapping between Python functions and text input.\n\nUsage\n-----\nYou know Flask_, right? You love the decorator-routing they use, right? - This is exactly the same, but for any text and\nnot URLs and with REGEX!\n\n.. _Flask: http://flask.pocoo.org/\n\n**Here is how you use it:**\n\nFirst you need to create an instance of the FuncMapper:\n\n.. code-block:: python\n\n from funcmap import FuncMapper\n\n mapper = FuncMapper()\n\nAnd now you map, map, map:\n\nThere are two ways supported to map a regex to a function.\nFirst using the map decorator:\n\n.. code-block:: python\n\n @mapper.map(r'call my_func')\n def my_func():\n \"\"\"We can map simple functions.\n\n Just pass a phrase to the map decorator.\n \"\"\"\n return 'I, my_func, have been called'\n\n\n @mapper.map(r'(?P\\d+)\\+(?P\\d+)')\n def adder(first, second):\n \"\"\"We can map functions with arguments.\n\n All named capture groups (this is a capture group named first: (?P\\d+)) are passed as keyword-arguments to\n function. So make sure the names of your capture groups fit the names of your function arguments.\n Unnamed capture groups as positional arguments are NOT supported to avoid some edge-cases!\n \"\"\"\n return '{} + {} = {}'.format(first, second, int(first) + int(second))\n\n... and second using map as a function:\n\n.. code-block:: python\n\n def my_func():\n \"\"\"We can map simple functions.\n\n Just pass a phrase to the map decorator.\n \"\"\"\n return 'I, my_func, have been called'\n\n\n def adder(first, second):\n \"\"\"We can map functions with arguments.\n\n All named capture groups (this is a capture group named first: (?P\\d+)) are passed as keyword-arguments to\n function. So make sure the names of your capture groups fit the names of your function arguments.\n Unnamed capture groups as positional arguments are NOT supported to avoid some edge-cases!\n \"\"\"\n return '{} + {} = {}'.format(first, second, int(first) + int(second))\n\n mapper.map(r'call my_func', my_func)\n mapper.map(r'(?P\\d+)\\+(?P\\d+)', adder)\n\nNot enough mapping? - Than map some more! Double-Map-Time!\n\n.. code-block:: python\n\n @mapper.map(r'I am Fred')\n @mapper.map(r'No, I am Joe')\n def multi_name():\n \"\"\"We can map multiple Regex-expressions to the same function.\"\"\"\n return 'I have multiple names!'\n\nAnd no we have a function with some self esteem:\n\n.. code-block:: python\n\n >>> print(mapper('call my_func'))\n 'I, my_func, have been called'\n\nA silly calculator:\n\n.. code-block:: python\n\n >>> print(mapper('3+5'))\n '3 + 5 = 8'\n >>> print(mapper('10+2'))\n '10 + 2 = 12'\n\nAnd this schizophrenic guy:\n\n.. code-block:: python\n\n >>> print('I am Fred')\n 'I have multiple names!'\n >>> print('No, I am Joe')\n 'I have multiple names!'\n\nFor more guidance check the examples folder and the method docstrings.\n\nWhy the heck do I need that?\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^\nBecause it uses some awesome Python stuff, of course! - But seriously, the idea is to use it as tiny helper-framework\nwhen some simple language logic is needed. A prime example would be something like a chatbot or some kind of AI-Assistant.\n\nI developed this little thing, because I am planning on building like a very dumb language-shortcut engine to make some\nsimple tasks voice or SMS/Message controllable. I currently don't have time for that, but I wanted to start somewhere.\nIf you have the time, STEAL MY IDEA, MAKE IT, SHARE IT, AND BE AWESOME!\n\nCan it do ...?\n^^^^^^^^^^^^^^\nProbably not... yet! Currently I only implemented the bare minimum I needed. If I will do more work with this library I\nwill very likely find more stuff I need. Till then, it is your turn! If you are missing a feature let me know! I will\ntry my best to make it work for you!\n\nWhat is this RegEx you are talking about?\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\nRegular Expressions (RegEx) are super cool language-processing-magic, if one understands them. I do... sometimes. If you want to\nmaster the RegEx `learn here `_ and `test your skills here `_.\n\n\nInstallation\n------------\n\n.. code-block:: bash\n\n pip install funcmap\n\nor if you want to develop an awesome new feature (yes, I know you want to!):\n\n.. code-block:: bash\n\n git clone https://github.com/AKuederle/funcmap.git\n cd funcmap\n pip install -e .\n\n\nWhat do I need?! (Requirements)\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\nNa Na Na Nothing\n\nBut, does it work?! (Tests)\n^^^^^^^^^^^^^^^^^^^^^^^^^^^\nYES! I hope. If in doubt, run\n\n.. code-block:: bash\n\n python setup.py test\n\nCompatibility\n-------------\n\nThe module is compatible with Python 3 only. It uses `re.fullmatch`, which is not backwards compatible. If you really\nneed a version that is compatible with Python 2.7, let me know. I guess it should be possible to fix that.\n\nLicence\n-------\nThis package is licenced under a MIT licence (Copyright (c) 2017 Arne K\u00fcderle)\n\nAuthors\n-------\n\n`funcmap` was written by `Arne K\u00fcderle `_.\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/AKuederle/funcmap", "keywords": "", "license": "LICENSE.txt", "maintainer": "", "maintainer_email": "", "name": "funcmap", "package_url": "https://pypi.org/project/funcmap/", "platform": "", "project_url": "https://pypi.org/project/funcmap/", "project_urls": { "Homepage": "https://github.com/AKuederle/funcmap" }, "release_url": "https://pypi.org/project/funcmap/1.0.3/", "requires_dist": null, "requires_python": "", "summary": "A small Python module to provide convenient mapping between Python functions and text input", "version": "1.0.3" }, "last_serial": 3489468, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "fb201d2ec3495ae7562fec81f74cbefb", "sha256": "175e30e173d04583866b1054ec12837a4321716c112ae899e3cfbbfaec3b1fbd" }, "downloads": -1, "filename": "funcmap-1.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "fb201d2ec3495ae7562fec81f74cbefb", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 10410, "upload_time": "2017-04-29T22:57:15", "url": "https://files.pythonhosted.org/packages/a7/7b/21cc0e135f45e3c2c5ca93c6ea92f59461135528503b1667227be30a1329/funcmap-1.0.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "7dfe0c961b3df12fb25879d026cc42e5", "sha256": "ef38112cd6912da757cd95542fcfba5fa24f7f22a0514a83993e1e11ef51e992" }, "downloads": -1, "filename": "funcmap-1.0.0.tar.gz", "has_sig": false, "md5_digest": "7dfe0c961b3df12fb25879d026cc42e5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6095, "upload_time": "2017-04-29T22:57:16", "url": "https://files.pythonhosted.org/packages/4b/76/5cf8885d2aeb26805512aea4f6a2e9e2840a759c65731ecfeec0f939a0e8/funcmap-1.0.0.tar.gz" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "31fe817df8490cc2b16ea7193a84e9ba", "sha256": "26af3e64b3f9cacbe8a7b936f4cfce22ebac0977161ca4ce5be7a0331d7eac14" }, "downloads": -1, "filename": "funcmap-1.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "31fe817df8490cc2b16ea7193a84e9ba", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 10439, "upload_time": "2017-04-29T23:10:10", "url": "https://files.pythonhosted.org/packages/80/d1/de63a72705cc15c325c015476ce3ac394807aff0c6d6ebc33012e9f75585/funcmap-1.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "525e7497d544c768d52ad20bdcc0a824", "sha256": "5e616d7b53a60cb3426aabc461bc86676ec2cf058cdc5404b34887b2d1f7ec2f" }, "downloads": -1, "filename": "funcmap-1.0.1.tar.gz", "has_sig": false, "md5_digest": "525e7497d544c768d52ad20bdcc0a824", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6071, "upload_time": "2017-04-29T23:10:12", "url": "https://files.pythonhosted.org/packages/6d/b4/a74d42b0ccbb857deabcfcbd7cb3497a12bb30cb08fed3d69f17a6a0725f/funcmap-1.0.1.tar.gz" } ], "1.0.2": [ { "comment_text": "", "digests": { "md5": "5f34be891c11e23823a6dbd00edefd3f", "sha256": "d2f488a1d292b10a03d080540a4a562f3e9f81ed64a52e4f3e9ca25508ac9972" }, "downloads": -1, "filename": "funcmap-1.0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "5f34be891c11e23823a6dbd00edefd3f", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 10859, "upload_time": "2018-01-10T08:54:25", "url": "https://files.pythonhosted.org/packages/d1/4a/1c8d89870f65776d1733f12c15ad8d9ec7ff5258b923ea8ddcd58ece8555/funcmap-1.0.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "df8d337b6178129580f5f564323755d2", "sha256": "adaac08da24f99b2fd2769bc237badd3678486667d5142be6eff0047799bcb80" }, "downloads": -1, "filename": "funcmap-1.0.2.tar.gz", "has_sig": false, "md5_digest": "df8d337b6178129580f5f564323755d2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6381, "upload_time": "2018-01-10T08:54:26", "url": "https://files.pythonhosted.org/packages/3f/3d/8a65f1c397d5e03fc44373daa719d6feea20bea3bae35a0bf7bc0ea03667/funcmap-1.0.2.tar.gz" } ], "1.0.3": [ { "comment_text": "", "digests": { "md5": "afb9fc272ff5a805c5bd3e7030977e38", "sha256": "5677024c8c518faf72da7dee7f2950d5225d1bed02bc42a923ed0ba1695fee59" }, "downloads": -1, "filename": "funcmap-1.0.3-py3-none-any.whl", "has_sig": false, "md5_digest": "afb9fc272ff5a805c5bd3e7030977e38", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 12054, "upload_time": "2018-01-14T21:13:22", "url": "https://files.pythonhosted.org/packages/ac/64/27a005b945de0961927ec4d62af7e0d5a6dac7438de9a3114ee9e280d95b/funcmap-1.0.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f8dfefb179b2873a3e0a43a04db7c00c", "sha256": "f6135fe1bb2d72ddfd2e03091d65a7ee49f0579a256a916b36d1b5971a621fe5" }, "downloads": -1, "filename": "funcmap-1.0.3.tar.gz", "has_sig": false, "md5_digest": "f8dfefb179b2873a3e0a43a04db7c00c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6964, "upload_time": "2018-01-14T21:13:25", "url": "https://files.pythonhosted.org/packages/76/ed/bd40fb98fb3a783b51d452cac3d1a1a84750d458351700846581fb0e561c/funcmap-1.0.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "afb9fc272ff5a805c5bd3e7030977e38", "sha256": "5677024c8c518faf72da7dee7f2950d5225d1bed02bc42a923ed0ba1695fee59" }, "downloads": -1, "filename": "funcmap-1.0.3-py3-none-any.whl", "has_sig": false, "md5_digest": "afb9fc272ff5a805c5bd3e7030977e38", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 12054, "upload_time": "2018-01-14T21:13:22", "url": "https://files.pythonhosted.org/packages/ac/64/27a005b945de0961927ec4d62af7e0d5a6dac7438de9a3114ee9e280d95b/funcmap-1.0.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f8dfefb179b2873a3e0a43a04db7c00c", "sha256": "f6135fe1bb2d72ddfd2e03091d65a7ee49f0579a256a916b36d1b5971a621fe5" }, "downloads": -1, "filename": "funcmap-1.0.3.tar.gz", "has_sig": false, "md5_digest": "f8dfefb179b2873a3e0a43a04db7c00c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6964, "upload_time": "2018-01-14T21:13:25", "url": "https://files.pythonhosted.org/packages/76/ed/bd40fb98fb3a783b51d452cac3d1a1a84750d458351700846581fb0e561c/funcmap-1.0.3.tar.gz" } ] }