{ "info": { "author": "metagriffin", "author_email": "mg.pypi@uberdev.org", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python" ], "description": "==========================\nGlob-Like Pattern Matching\n==========================\n\nConverts a glob-matching pattern to a regular expression, using Apache\nCocoon style rules (with some extensions).\n\nTL;DR\n=====\n\nInstall:\n\n.. code:: bash\n\n $ pip install globre\n\nUse:\n\n.. code:: python\n\n import globre\n\n names = [\n '/path/to/file.txt',\n '/path/to/config.ini',\n '/path/to/subdir/base.ini',\n ]\n\n txt_names = [name for name in names if globre.match('/path/to/*.txt', name)]\n assert txt_names == ['/path/to/file.txt']\n\n ini_names = [name for name in names if globre.match('/path/to/*.ini', name)]\n assert ini_names == ['/path/to/config.ini']\n\n all_ini_names = [name for name in names if globre.match('/path/to/**.ini', name)]\n assert all_ini_names == ['/path/to/config.ini', '/path/to/subdir/base.ini']\n\n\nDetails\n=======\n\nThis package basically allows using unix shell-like filename globbing\nto be used to match a string in a Python program. The glob matching\nallows most characters to match themselves, with the following\nsequences having special meanings:\n\n========= ====================================================================\nSequence Meaning\n========= ====================================================================\n``?`` Matches any single character except the slash\n ('/') character.\n``*`` Matches zero or more characters *excluding* the slash\n ('/') character, e.g. ``/etc/*.conf`` which will *not*\n match \"/etc/foo/bar.conf\".\n``**`` Matches zero or more characters *including* the slash\n ('/') character, e.g. ``/lib/**.so`` which *will*\n match \"/lib/foo/bar.so\".\n``\\`` Escape character used to precede any of the other special\n characters (in order to match them literally), e.g.\n ``foo\\?`` will match \"foo\" followed by a literal question mark.\n``[...]`` Matches any character in the specified regex-style character range,\n e.g. ``foo[0-9A-F].conf``.\n``{...}`` Inlines a regex expression, e.g. ``foo-{\\\\D{2,4\\}}.txt`` which\n will match \"foo-bar.txt\" but not \"foo-012.txt\".\n========= ====================================================================\n\nThe `globre` package exports the following functions:\n\n* ``globre.match(pattern, string, sep=None, flags=0)``:\n\n Tests whether or not the glob `pattern` matches the `string`. If it\n does, a `re.MatchObject` is returned, otherwise ``None``. The `string`\n must be matched in its entirety. See `globre.compile` for details on\n the `sep` and `flags` parameters. Example:\n\n .. code:: python\n\n globre.match('/etc/**.conf', '/etc/rsyslog.conf')\n # => truthy\n\n* ``globre.search(pattern, string, sep=None, flags=0)``:\n\n Similar to `globre.match`, but the pattern does not need to match\n the entire string. Example:\n\n .. code:: python\n\n globre.search('lib/**.so', '/var/lib/python/readline.so.6.2')\n # => truthy\n\n* ``globre.compile(pattern, sep=None, flags=0, split_prefix=False)``:\n\n Compiles the specified `pattern` into a matching object that has the\n same API as the regular expression object returned by `re.compile`.\n\n The `sep` parameter specifies the hierarchical path component\n separator to use. By default, it uses the unix-style forward-slash\n separator (``\"/\"``), but can be overriden to be a sequence of\n alternative valid hierarchical path component separator characters.\n Note that although `sep` *could* be set to both forward- and back-\n slashes (i.e. ``\"/\\\\\"``) to, theoretically, support either unix- and\n windows-style path components, this has the significant flaw that\n then *both* characters can be used within the same path as\n separators.\n\n The `flags` bit mask can contain all the standard `re` flags, in\n addition to the ``globre.EXACT`` flag. If EXACT is set, then the\n returned regex will include the equivalent of a leading '^' and\n trailing '$', meaning that the regex must match the entire string,\n from beginning to end.\n\n If `split_prefix` is truthy, the return value becomes a tuple with\n the first element set to any initial non-wildcarded string found in\n the pattern. The second element remains the regex object as before.\n For example, the pattern ``foo/**.ini`` would result in a tuple\n equivalent to ``('foo/', re.compile('foo/.*\\\\.ini'))``.\n\n Example:\n\n .. code:: python\n\n prefix, expr = globre.compile('/path/to**.ini', split_prefix=True)\n # prefix => '/path/to'\n\n names = [\n '/path/to/file.txt',\n '/path/to/config.ini',\n '/path/to/subdir/otherfile.txt',\n '/path/to/subdir/base.ini',\n ]\n\n for name in names:\n if not expr.match(name):\n # ignore the two \".txt\" files\n continue\n # and do something with:\n # - /path/to/config.ini\n # - /path/to/subdir/base.ini\n\n\nWhat About the ``glob`` Module\n==============================\n\nThis package is different from the standard Python `glob` module in\nthe following critical ways:\n\n* The `glob` module operates on the actual filesystem; `globre` can be\n used to match both files on the filesystem as well as any other\n sources of strings to match.\n\n* The `glob` module does not provide the ``**`` \"descending\" matcher.\n\n* The `glob` module does not provide the ``{...}`` regular expression\n inlining feature.\n\n* The `glob` module does not provide an alternate hierarchy separator\n beyond ``/`` or ``\\\\``.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/metagriffin/globre", "keywords": "python glob pattern matching regular expression", "license": "GPLv3+", "maintainer": null, "maintainer_email": null, "name": "globre", "package_url": "https://pypi.org/project/globre/", "platform": "any", "project_url": "https://pypi.org/project/globre/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://github.com/metagriffin/globre" }, "release_url": "https://pypi.org/project/globre/0.1.5/", "requires_dist": null, "requires_python": null, "summary": "A glob matching library, providing an interface similar to the \"re\" module.", "version": "0.1.5" }, "last_serial": 2430819, "releases": { "0.0.1": [], "0.0.4": [ { "comment_text": "", "digests": { "md5": "e7774c2c9868ed0aba310ad7476b243b", "sha256": "a28442ed8f62bca04ce0cb54b2480db3bf430f983030c7d7749d6066b61eedcd" }, "downloads": -1, "filename": "globre-0.0.4.tar.gz", "has_sig": false, "md5_digest": "e7774c2c9868ed0aba310ad7476b243b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4589, "upload_time": "2013-10-30T23:14:13", "url": "https://files.pythonhosted.org/packages/c8/82/190027afef1c0bb4ebf8d070230bc4b82c33b08ae627a3289df8adde942a/globre-0.0.4.tar.gz" } ], "0.0.5": [ { "comment_text": "", "digests": { "md5": "45280c0fde3f175cbdf08b001d488fb9", "sha256": "702638e72cbfd08e9f8e16f041904987a7dbc773d0e04e2cd88109e7330f9cb9" }, "downloads": -1, "filename": "globre-0.0.5.tar.gz", "has_sig": false, "md5_digest": "45280c0fde3f175cbdf08b001d488fb9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6032, "upload_time": "2013-10-31T01:11:09", "url": "https://files.pythonhosted.org/packages/23/7b/79b92a4ea4d8554f16915d8a2fc7615afde748153ed5624c7283ba00e597/globre-0.0.5.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "8fed2d9b364c027777b07e867baf7284", "sha256": "64203a0caca50cf2048cc4cc18b8abf452dfb7822b79ea9950f7c0ee03f51d9b" }, "downloads": -1, "filename": "globre-0.1.2.tar.gz", "has_sig": false, "md5_digest": "8fed2d9b364c027777b07e867baf7284", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18465, "upload_time": "2013-11-20T17:24:27", "url": "https://files.pythonhosted.org/packages/61/88/858e3c80a1c6466eacead2c3ce694785a20b89f33ff1012c466fb553a4a7/globre-0.1.2.tar.gz" } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "23c5e6141e7e871a017d1b56729db421", "sha256": "482527dc342a88945edfbfe4d78b0c546b163b2a6579863ebfd6b3b5df222e5a" }, "downloads": -1, "filename": "globre-0.1.3.tar.gz", "has_sig": false, "md5_digest": "23c5e6141e7e871a017d1b56729db421", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 19205, "upload_time": "2015-08-17T22:25:48", "url": "https://files.pythonhosted.org/packages/a2/41/1790b593f0a0c0190c24104c1c396d3f30404b0facf3fa4eb516b48c4f0c/globre-0.1.3.tar.gz" } ], "0.1.4": [ { "comment_text": "", "digests": { "md5": "0caf9cedfc37d3581c47e196d5b2f3cd", "sha256": "eab210811e7dbdf8ef698cc6b8d9e4b218cfe16e8286520cea78a509de4fbd91" }, "downloads": -1, "filename": "globre-0.1.4.tar.gz", "has_sig": false, "md5_digest": "0caf9cedfc37d3581c47e196d5b2f3cd", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 19274, "upload_time": "2016-04-13T03:34:42", "url": "https://files.pythonhosted.org/packages/60/10/97357227fee66c8824cfcfd12e51f9cae66aa7c4d5055c6fa7cb8b3b1141/globre-0.1.4.tar.gz" } ], "0.1.5": [ { "comment_text": "", "digests": { "md5": "9dac11b1a0c822ea38ab2816f3194319", "sha256": "ee214204f237e9114b8f61eeb61c2abd1e665ca3b59e5a6a0b070971c0bb12e2" }, "downloads": -1, "filename": "globre-0.1.5.tar.gz", "has_sig": false, "md5_digest": "9dac11b1a0c822ea38ab2816f3194319", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 20388, "upload_time": "2016-10-29T20:19:27", "url": "https://files.pythonhosted.org/packages/5a/ce/a9e2f3317a458f8c591a1f95d4061d4e241f529ba678292acdcf2d804783/globre-0.1.5.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "9dac11b1a0c822ea38ab2816f3194319", "sha256": "ee214204f237e9114b8f61eeb61c2abd1e665ca3b59e5a6a0b070971c0bb12e2" }, "downloads": -1, "filename": "globre-0.1.5.tar.gz", "has_sig": false, "md5_digest": "9dac11b1a0c822ea38ab2816f3194319", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 20388, "upload_time": "2016-10-29T20:19:27", "url": "https://files.pythonhosted.org/packages/5a/ce/a9e2f3317a458f8c591a1f95d4061d4e241f529ba678292acdcf2d804783/globre-0.1.5.tar.gz" } ] }