gitmatch


Namegitmatch JSON
Version 0.2.0 PyPI version JSON
download
home_pageNone
SummaryGitignore-style path matching
upload_time2024-07-28 17:48:12
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseNone
keywords fnmatch git gitignore glob wildmatch
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            |repostatus| |ci-status| |coverage| |pyversions| |license|

.. |repostatus| image:: https://www.repostatus.org/badges/latest/active.svg
    :target: https://www.repostatus.org/#active
    :alt: Project Status: Active — The project has reached a stable, usable
          state and is being actively developed.

.. |ci-status| image:: https://github.com/jwodder/gitmatch/actions/workflows/test.yml/badge.svg
    :target: https://github.com/jwodder/gitmatch/actions/workflows/test.yml
    :alt: CI Status

.. |coverage| image:: https://codecov.io/gh/jwodder/gitmatch/branch/master/graph/badge.svg
    :target: https://codecov.io/gh/jwodder/gitmatch

.. |pyversions| image:: https://img.shields.io/pypi/pyversions/gitmatch.svg
    :target: https://pypi.org/project/gitmatch/

.. |license| image:: https://img.shields.io/github/license/jwodder/gitmatch.svg
    :target: https://opensource.org/licenses/MIT
    :alt: MIT License

`GitHub <https://github.com/jwodder/gitmatch>`_
| `PyPI <https://pypi.org/project/gitmatch/>`_
| `Documentation <https://gitmatch.readthedocs.io>`_
| `Issues <https://github.com/jwodder/gitmatch/issues>`_
| `Changelog <https://github.com/jwodder/gitmatch/blob/master/CHANGELOG.md>`_

``gitmatch`` provides ``gitignore``-style pattern matching of file paths.
Simply pass in a sequence of ``gitignore`` patterns and you'll get back an
object for testing whether a given relative path matches the patterns.

Installation
============
``gitmatch`` requires Python 3.8 or higher.  Just use `pip
<https://pip.pypa.io>`_ for Python 3 (You have pip, right?) to install it::

    python3 -m pip install gitmatch


Examples
========

Basic usage::

    >>> import gitmatch
    >>> gi = gitmatch.compile(["foo", "!bar", "*.dir/"])
    >>> bool(gi.match("foo"))
    True
    >>> bool(gi.match("bar"))
    False
    >>> bool(gi.match("quux"))
    False
    >>> bool(gi.match("foo/quux"))
    True
    >>> bool(gi.match("foo/bar"))
    True
    >>> bool(gi.match("bar/foo"))
    True
    >>> bool(gi.match("bar/quux"))
    False
    >>> bool(gi.match("foo.dir"))
    False
    >>> bool(gi.match("foo.dir/"))
    True

See what pattern was matched::

    >>> m1 = gi.match("foo/bar")
    >>> m1 is None
    False
    >>> bool(m1)
    True
    >>> m1.pattern
    'foo'
    >>> m1.path
    'foo'
    >>> m2 = gi.match("bar")
    >>> m2 is None
    False
    >>> bool(m2)
    False
    >>> m2.pattern
    '!bar'
    >>> m2.pattern_obj.negative
    True
    >>> m3 = gi.match("quux")
    >>> m3 is None
    True

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "gitmatch",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "fnmatch, git, gitignore, glob, wildmatch",
    "author": null,
    "author_email": "John Thorvald Wodder II <gitmatch@varonathe.org>",
    "download_url": "https://files.pythonhosted.org/packages/c4/03/3b7dc756867ccef54f99c72b96b431c72c9161d80851eebab8ac247ef32b/gitmatch-0.2.0.tar.gz",
    "platform": null,
    "description": "|repostatus| |ci-status| |coverage| |pyversions| |license|\n\n.. |repostatus| image:: https://www.repostatus.org/badges/latest/active.svg\n    :target: https://www.repostatus.org/#active\n    :alt: Project Status: Active \u2014 The project has reached a stable, usable\n          state and is being actively developed.\n\n.. |ci-status| image:: https://github.com/jwodder/gitmatch/actions/workflows/test.yml/badge.svg\n    :target: https://github.com/jwodder/gitmatch/actions/workflows/test.yml\n    :alt: CI Status\n\n.. |coverage| image:: https://codecov.io/gh/jwodder/gitmatch/branch/master/graph/badge.svg\n    :target: https://codecov.io/gh/jwodder/gitmatch\n\n.. |pyversions| image:: https://img.shields.io/pypi/pyversions/gitmatch.svg\n    :target: https://pypi.org/project/gitmatch/\n\n.. |license| image:: https://img.shields.io/github/license/jwodder/gitmatch.svg\n    :target: https://opensource.org/licenses/MIT\n    :alt: MIT License\n\n`GitHub <https://github.com/jwodder/gitmatch>`_\n| `PyPI <https://pypi.org/project/gitmatch/>`_\n| `Documentation <https://gitmatch.readthedocs.io>`_\n| `Issues <https://github.com/jwodder/gitmatch/issues>`_\n| `Changelog <https://github.com/jwodder/gitmatch/blob/master/CHANGELOG.md>`_\n\n``gitmatch`` provides ``gitignore``-style pattern matching of file paths.\nSimply pass in a sequence of ``gitignore`` patterns and you'll get back an\nobject for testing whether a given relative path matches the patterns.\n\nInstallation\n============\n``gitmatch`` requires Python 3.8 or higher.  Just use `pip\n<https://pip.pypa.io>`_ for Python 3 (You have pip, right?) to install it::\n\n    python3 -m pip install gitmatch\n\n\nExamples\n========\n\nBasic usage::\n\n    >>> import gitmatch\n    >>> gi = gitmatch.compile([\"foo\", \"!bar\", \"*.dir/\"])\n    >>> bool(gi.match(\"foo\"))\n    True\n    >>> bool(gi.match(\"bar\"))\n    False\n    >>> bool(gi.match(\"quux\"))\n    False\n    >>> bool(gi.match(\"foo/quux\"))\n    True\n    >>> bool(gi.match(\"foo/bar\"))\n    True\n    >>> bool(gi.match(\"bar/foo\"))\n    True\n    >>> bool(gi.match(\"bar/quux\"))\n    False\n    >>> bool(gi.match(\"foo.dir\"))\n    False\n    >>> bool(gi.match(\"foo.dir/\"))\n    True\n\nSee what pattern was matched::\n\n    >>> m1 = gi.match(\"foo/bar\")\n    >>> m1 is None\n    False\n    >>> bool(m1)\n    True\n    >>> m1.pattern\n    'foo'\n    >>> m1.path\n    'foo'\n    >>> m2 = gi.match(\"bar\")\n    >>> m2 is None\n    False\n    >>> bool(m2)\n    False\n    >>> m2.pattern\n    '!bar'\n    >>> m2.pattern_obj.negative\n    True\n    >>> m3 = gi.match(\"quux\")\n    >>> m3 is None\n    True\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Gitignore-style path matching",
    "version": "0.2.0",
    "project_urls": {
        "Bug Tracker": "https://github.com/jwodder/gitmatch/issues",
        "Documentation": "https://gitmatch.readthedocs.io",
        "Source Code": "https://github.com/jwodder/gitmatch"
    },
    "split_keywords": [
        "fnmatch",
        " git",
        " gitignore",
        " glob",
        " wildmatch"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "288305bd9481ccd80f497936e2587ee846106af862a7dae8a52116b35e1d4082",
                "md5": "7fbc60865d80dfedb8e9fa88621ab72e",
                "sha256": "9c67d74b9dd32e06ffd0a079cffdcc764e9d8a0281b981487ed21699c030e1a0"
            },
            "downloads": -1,
            "filename": "gitmatch-0.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "7fbc60865d80dfedb8e9fa88621ab72e",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 7970,
            "upload_time": "2024-07-28T17:48:07",
            "upload_time_iso_8601": "2024-07-28T17:48:07.220376Z",
            "url": "https://files.pythonhosted.org/packages/28/83/05bd9481ccd80f497936e2587ee846106af862a7dae8a52116b35e1d4082/gitmatch-0.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c4033b7dc756867ccef54f99c72b96b431c72c9161d80851eebab8ac247ef32b",
                "md5": "6c6ea66a7c420955cdd328eae1e33184",
                "sha256": "b9e1b4b9336f5013b30a9929fdc037a68e3971e2c30545d8ba50a4e81931a0a5"
            },
            "downloads": -1,
            "filename": "gitmatch-0.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "6c6ea66a7c420955cdd328eae1e33184",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 16233,
            "upload_time": "2024-07-28T17:48:12",
            "upload_time_iso_8601": "2024-07-28T17:48:12.880091Z",
            "url": "https://files.pythonhosted.org/packages/c4/03/3b7dc756867ccef54f99c72b96b431c72c9161d80851eebab8ac247ef32b/gitmatch-0.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-07-28 17:48:12",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "jwodder",
    "github_project": "gitmatch",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "gitmatch"
}
        
Elapsed time: 0.31835s