{ "info": { "author": "Biagio Distefano", "author_email": "biagiodistefano92@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "replus\n======\n\nA wrapper for the ``regex`` library for advanced pattern management\n\nInstallation\n------------\n\n``pip install replus``\n\nor clone this repo\n\n``git@github.com:raptored01/replus.git``\n\nand then run\n\n``python setup.py install``\n\nBasic usage\n-----------\n\nThe Engine loads Regular Expression **pattern templates** written in\n\\*.json files from the provided directory, builds and compiles them in\nthe following fashion:\n\nexample of template ``models/dates.json``:\n\n::\n\n {\n \"day\": [\n \"3[01]\",\n \"[12][0-9]\",\n \"0?[1-9]\"\n ],\n \"month\": [\n \"0?[1-9]\",\n \"1[012]\"\n ],\n \"year\": [\n \"\\\\d{4}\"\n ],\n \"date\": [\n \"{{day}}/{{month}}/{{year}}\",\n \"{{year}}-{{month}}-{{day}}\"\n ],\n \"patterns\": [\n \"{{date}}\"\n ]\n }\n\nwill result in the following regex:\n\n``(?P(?P[12][0-9]|0?[1-9]|3[01])/(?P0?[1-9]|1[012])/(?P\\d{4})|(?P\\d{4})-(?P0?[1-9]|1[012])-(?P[12][0-9]|0?[1-9]|3[01]))``\n\nYou can put more patterns into ``patterns``, as it will become a ``list`` that will be looped over.\n\nQuerying\n--------\n\nIt is possible to query as follows:\n\n::\n\n from replus import Engine\n\n engine = Engine('models')\n\n for match in engine.parse(\"Look at this date: 2012-20-10\"):\n print(match)\n # <[Match date] span(19, 29): 2012-12-10>\n\n date = match.group('date')\n print(date)\n # <[Group date_0] span(19, 29): 2012-12-10>\n\n day = date.group('day')\n print(day)\n # <[Group day_1] span(27, 29): 10>\n\n month = date.group('month')\n print(month)\n # <[Group month_1] span(24, 26): 12>\n\n year = date.group('year')\n print(year)\n # [Group year_1] span(19, 23): 2012>\n\nFiltering\n---------\n\nit is possible to filter regexes by type, being the type given by the json's filename\n\n::\n\n filters = [\"dates\", \"cities\"]\n for match in engine.parse(my_string, *filters):\n # do stuff\n\n\n\nMatch and Group objects\n-----------------------\n\nMatch objects have the following attributes:\n\n- ``type``: the type of match (e.g. \"dates\");\n- ``match``: the re.match object;\n- ``re``: the regex pattern;\n- ``all_group_names``: the name of all the children groups;\n\nBoth Match and Group objects have the following attributes:\n\n- ``value``: the string value of the match/group\n- ``start``: the beginning of the match/group relative to the input string\n- ``end``: the end of the group relative to the input string\n- ``span``: ``(start, end)`` the span of the match/group object relative to the input string\n- ``offset``: ``{\"start\": start, \"end\": end}`` similar to ``span``\n- ``length``: end-start\n- ``first()``: get the first matching group\n- ``last()``: get the last matching group\n\nGroup objects have the following attributes:\n\n- ``name``: the actual group name (e.g. date\\_1);\n- ``key``: the group key (e.g. date);\n- ``spans``: ``[(start, end), ...]`` the spans of the repeated matches relative to the input string\n- ``starts``: the beginnings of the match/group relative to the input string\n- ``ends``: the ends of the group relative to the input string\n- ``offsets``: ``[{\"start\": start, \"end\": end}, ...]``\n\nBoth Match and Group objects can be serialized in dicts with the ``serialize()`` method and\nto a json string with the ``json`` attribute\n\nSecondary features\n~~~~~~~~~~~~~~~~~~\n\nThere are two useful secondary features:\n\n- ``non-capturing groups``: these are specified by using the \"?:\" prefix\n in the group name or key\n- ``atomic groups``: these are specified by using the \"?>\" prefix\n in the group name or key\n- ``dynamic backreferences``: use ``#`` to reference a previous group\n and ``@`` to specify how many groups behind\n\ntemplate:\n\n::\n\n {\n \"?:number\": [\n \"\\\\d\"\n ],\n \"abg\": [\n \"alpha\",\n \"beta\",\n \"gamma\"\n ],\n \"spam\": [\n \"spam\"\n ],\n \"eggs\": [\n \"eggs\"\n ],\n \"patterns\": [\n \"This is an unnamed number group: {{number}}.\",\n \"I can match {{abg}} and {{abg}}, and then re-match the last {{#abg}} or the second last {{#abg@2}}\",\n \"Here is some {{?:spam}} and some {{?>eggs}}\"\n ]\n }\n\nIt will generate the following regexs:\n\n``This is an unnamed number group: (?:\\d).``\n\n``I can match (?Palpha|beta|gamma) and (?Palpha|beta|gamma), and then re-match the last (?P=abg_1) or the second last (?P=abg_0)``\n\n``Here is some (?:spam) and some (?>eggs)``\n\n**N.B.**: in order to obtain an escape char, such as ``\\d``, in the\npattern's model it **must** be double escaped: ``\\\\d``\n\nCurrent limitations\n~~~~~~~~~~~~~~~~~~~\n\nNone known\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/raptored01/replus", "keywords": "", "license": "LICENSE", "maintainer": "", "maintainer_email": "", "name": "replus", "package_url": "https://pypi.org/project/replus/", "platform": "any", "project_url": "https://pypi.org/project/replus/", "project_urls": { "Homepage": "https://github.com/raptored01/replus" }, "release_url": "https://pypi.org/project/replus/0.1.1/", "requires_dist": [ "regex (>=2019.8.19)" ], "requires_python": "", "summary": "A wrapper for Python's re library for advanced regex pattern management", "version": "0.1.1" }, "last_serial": 5938211, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "573a7f2988eb04c31342fcb05ed6938b", "sha256": "14fc7e7aeb793a29b49adb1952ce013178787851cac54a1640c0116c34810d80" }, "downloads": -1, "filename": "replus-0.0.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "573a7f2988eb04c31342fcb05ed6938b", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 6973, "upload_time": "2019-03-12T13:52:28", "url": "https://files.pythonhosted.org/packages/b6/37/3c0ad76049b1d8c622f5545b7a59a58b57e5f91003224007e8e229e39951/replus-0.0.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "b39d5af30b9628b1de3e9e9408806a11", "sha256": "ac803768a16a2cd9a9b8e327130b9953bdbe03907b52ff32e5bc40508dcbe977" }, "downloads": -1, "filename": "replus-0.0.1.tar.gz", "has_sig": false, "md5_digest": "b39d5af30b9628b1de3e9e9408806a11", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6085, "upload_time": "2019-03-12T13:52:30", "url": "https://files.pythonhosted.org/packages/a0/c8/594b70fa36e1777d3a43353cd1d501f2f86851b82740e4e18a512aab418b/replus-0.0.1.tar.gz" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "9f5c37cbc53a7a634bacfd6cf4459b4e", "sha256": "0701483cba6318ccdaddf4c64a1f337ebf55ca266046c8f116066d8b1abce7aa" }, "downloads": -1, "filename": "replus-0.0.2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "9f5c37cbc53a7a634bacfd6cf4459b4e", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 7050, "upload_time": "2019-03-12T14:26:56", "url": "https://files.pythonhosted.org/packages/ac/f8/8a0e9d4348ef0a6d905cdffcc5a7e7fbd31c6cd5c8b64572eb4b2ccf1431/replus-0.0.2-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "4491a8f09180dac613c059954a6abbe8", "sha256": "74a2cc5d12f830e689e417966043d4c51a24a9941e0d4dfdc6d4d8c9036c7793" }, "downloads": -1, "filename": "replus-0.0.2.tar.gz", "has_sig": false, "md5_digest": "4491a8f09180dac613c059954a6abbe8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6172, "upload_time": "2019-03-12T14:27:13", "url": "https://files.pythonhosted.org/packages/71/90/2e012c23458c9750c0cd22cbccc4639482df123b9b3c40787586415e9432/replus-0.0.2.tar.gz" } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "66bbc8659bbc736e249bf57ae1fdcc89", "sha256": "7814d5c34510e0ea7da0f531efaf665c096d1cfc676695450b9611a97b6d31a3" }, "downloads": -1, "filename": "replus-0.0.3-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "66bbc8659bbc736e249bf57ae1fdcc89", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 7050, "upload_time": "2019-03-12T14:41:52", "url": "https://files.pythonhosted.org/packages/ae/74/1abcd96b72f80eef3f85ec76843c39c280fc645c63f46e678eb1fe983d23/replus-0.0.3-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "9ba041618416b310cb99c2274cbf262c", "sha256": "2066c15782c6239cffe9e8ec21d69aa88caf4ae95b18204c72de22ef7f3078fb" }, "downloads": -1, "filename": "replus-0.0.3.tar.gz", "has_sig": false, "md5_digest": "9ba041618416b310cb99c2274cbf262c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6187, "upload_time": "2019-03-12T14:41:56", "url": "https://files.pythonhosted.org/packages/aa/1c/0b8e83f6ef5baf871ec101e82687b0d43ed04e1c13ba9bfb5a0d04bf36a5/replus-0.0.3.tar.gz" } ], "0.0.4": [ { "comment_text": "", "digests": { "md5": "383cdb36c43dc343818236c780d1a161", "sha256": "5e3f3434347b846fd4f9121b24fa5137bfd012a0401d43428c40daee91f5d3f6" }, "downloads": -1, "filename": "replus-0.0.4-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "383cdb36c43dc343818236c780d1a161", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 7052, "upload_time": "2019-03-20T15:04:43", "url": "https://files.pythonhosted.org/packages/4a/08/ea3fc09596d28fd5464cc1fdb93d8d42fa683738c025dd061b190f302d0f/replus-0.0.4-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "53b4651c64e5cc0a0d291227870d039c", "sha256": "e527251080f88a95685760913621f0e13e2b3a8fa393a6ae362ce13807a98734" }, "downloads": -1, "filename": "replus-0.0.4.tar.gz", "has_sig": false, "md5_digest": "53b4651c64e5cc0a0d291227870d039c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6200, "upload_time": "2019-03-20T15:04:49", "url": "https://files.pythonhosted.org/packages/ed/4b/2972e1e8e06e1fe34856041cb80d49196256508051646fe294c74ed3b72b/replus-0.0.4.tar.gz" } ], "0.0.5": [ { "comment_text": "", "digests": { "md5": "f22cbdaafceb776087e46c845c119fc1", "sha256": "414dd2c14477eece6ee71a651cac53eb8ea30c9a44ce80597fb9448a8fb52d59" }, "downloads": -1, "filename": "replus-0.0.5-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "f22cbdaafceb776087e46c845c119fc1", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 7047, "upload_time": "2019-04-01T16:13:11", "url": "https://files.pythonhosted.org/packages/1c/91/ef9bb5d5556a9a687bb4e76bdd032f11ef0d8f10dff6aedb02855732ef94/replus-0.0.5-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "02a418d3d1c5346f38cfd9f9af1d8d9a", "sha256": "c32bb807ef2f46af4da2f3514b0eb0bbefe2562ba0e0d7fcc24bedb006385320" }, "downloads": -1, "filename": "replus-0.0.5.tar.gz", "has_sig": false, "md5_digest": "02a418d3d1c5346f38cfd9f9af1d8d9a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6178, "upload_time": "2019-04-01T16:13:15", "url": "https://files.pythonhosted.org/packages/e4/f4/674c9a98821af2d6f81aedbf3cf7e209a8efd8d7498df3873e1c61f43b45/replus-0.0.5.tar.gz" } ], "0.0.6": [ { "comment_text": "", "digests": { "md5": "62d9741c7aee1ef3994122983fa5d9c6", "sha256": "0eeb941b7d25abc15f7ead2080071c2d440823d4d096b3738fd0a4a5ffc5b4bf" }, "downloads": -1, "filename": "replus-0.0.6-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "62d9741c7aee1ef3994122983fa5d9c6", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 7081, "upload_time": "2019-04-02T10:15:53", "url": "https://files.pythonhosted.org/packages/34/fb/19dc8d5b4a4678a7caeffa621b9fc03516aae72fc11c9a3cacb03e087d9f/replus-0.0.6-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "b14828e301b3492eab19d2b279962949", "sha256": "b9aa7350ab6a8289dc0babda9af83d8bb6aaa3ad3b7b46fa44889d447ee3af69" }, "downloads": -1, "filename": "replus-0.0.6.tar.gz", "has_sig": false, "md5_digest": "b14828e301b3492eab19d2b279962949", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6228, "upload_time": "2019-04-02T10:15:57", "url": "https://files.pythonhosted.org/packages/59/ef/600ce4db7bd6b9d2f5b67174428d1b5aeaef61a16495d0b1c88e8a755f1a/replus-0.0.6.tar.gz" } ], "0.0.7": [ { "comment_text": "", "digests": { "md5": "5a86515ff112c247ae776eb61d4a06c1", "sha256": "0780d4c5dacb195f590dad95217f9cb6c068326abc513ec7ba9edb18c5c23682" }, "downloads": -1, "filename": "replus-0.0.7-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "5a86515ff112c247ae776eb61d4a06c1", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 7174, "upload_time": "2019-06-06T10:04:34", "url": "https://files.pythonhosted.org/packages/0c/6d/c8f56b801ca292e4de40e65fc3681d599259ca66a2970fe5f1464e400b28/replus-0.0.7-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "5eac13d73de431ce20629c6304421490", "sha256": "04c2712b33879d09dcff7512d997b2098767b94be0f359a30df13645ba43f1a3" }, "downloads": -1, "filename": "replus-0.0.7.tar.gz", "has_sig": false, "md5_digest": "5eac13d73de431ce20629c6304421490", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6311, "upload_time": "2019-06-06T10:04:36", "url": "https://files.pythonhosted.org/packages/59/67/0caa671eca3550d18b322625cf3a9d23747ef9bd189d6f9c7a7f5b5634a2/replus-0.0.7.tar.gz" } ], "0.1.0": [ { "comment_text": "", "digests": { "md5": "fb6283ff568c49a9c0b2e61d6cb0e00c", "sha256": "26b41a54876c034205ed3418ae371be149e106525e971bad3a5318808a6dc805" }, "downloads": -1, "filename": "replus-0.1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "fb6283ff568c49a9c0b2e61d6cb0e00c", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 7871, "upload_time": "2019-09-30T09:31:58", "url": "https://files.pythonhosted.org/packages/e4/23/11009a97db686d7afd9821e83173b333d25848bb88291634c21d4ced35b2/replus-0.1.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "21020153769ab13714841cc2cbfc7f83", "sha256": "3924672eb89489ade22ffb985353a0e21bf1f682f7ac88653e42ab81ac9824cb" }, "downloads": -1, "filename": "replus-0.1.0.tar.gz", "has_sig": false, "md5_digest": "21020153769ab13714841cc2cbfc7f83", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7142, "upload_time": "2019-09-30T09:32:03", "url": "https://files.pythonhosted.org/packages/00/ad/456e89a30caac6421894b3286e0344dc32ed313f9eb41638f37872664f01/replus-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "91acddffeeefb1c8477a9d047090689f", "sha256": "b9ceac45e54cd7dbc8b88b2a63b23b320c781e3e3f05a0398222aa740992e205" }, "downloads": -1, "filename": "replus-0.1.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "91acddffeeefb1c8477a9d047090689f", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 7905, "upload_time": "2019-10-07T11:23:12", "url": "https://files.pythonhosted.org/packages/e2/ac/dd4b1e200414006085fb6c8c804882cc13a9090e0c556a19bce0c0f760db/replus-0.1.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "bf2a880cf5e0da506acf2db15d2b8456", "sha256": "ee4a7bd0536c08de755d727b70090bae0b6432d690214ca1823ed3b8ddc55328" }, "downloads": -1, "filename": "replus-0.1.1.tar.gz", "has_sig": false, "md5_digest": "bf2a880cf5e0da506acf2db15d2b8456", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7184, "upload_time": "2019-10-07T11:23:19", "url": "https://files.pythonhosted.org/packages/4a/e5/ee719ac927e9b698b363c45a85ffd253671f3a46a3f81a5aefb593ad235b/replus-0.1.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "91acddffeeefb1c8477a9d047090689f", "sha256": "b9ceac45e54cd7dbc8b88b2a63b23b320c781e3e3f05a0398222aa740992e205" }, "downloads": -1, "filename": "replus-0.1.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "91acddffeeefb1c8477a9d047090689f", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 7905, "upload_time": "2019-10-07T11:23:12", "url": "https://files.pythonhosted.org/packages/e2/ac/dd4b1e200414006085fb6c8c804882cc13a9090e0c556a19bce0c0f760db/replus-0.1.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "bf2a880cf5e0da506acf2db15d2b8456", "sha256": "ee4a7bd0536c08de755d727b70090bae0b6432d690214ca1823ed3b8ddc55328" }, "downloads": -1, "filename": "replus-0.1.1.tar.gz", "has_sig": false, "md5_digest": "bf2a880cf5e0da506acf2db15d2b8456", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7184, "upload_time": "2019-10-07T11:23:19", "url": "https://files.pythonhosted.org/packages/4a/e5/ee719ac927e9b698b363c45a85ffd253671f3a46a3f81a5aefb593ad235b/replus-0.1.1.tar.gz" } ] }