Metadata-Version: 2.3
Name: gitignore-lib
Version: 0.1.1
Summary: Simple tool to parse and use .gitignore files.
Author: chips
Author-email: chips <fabiomacedomendes@gmail.com>
Requires-Python: >=3.13
Description-Content-Type: text/markdown

# gitignore_lib

This library (and simple CLI application) parses and applies rules from
`.gitignore` files. It can be used to provide gitignore-like functionality
to your applications with a familiar syntax and behavior.


## Installation

It is available on PyPI: https://pypi.org/project/gitignore-lib/. So use the
default Python ways:

```bash
pip install gitignore_lib
```

If you are interested in using the CLI tool (it is not very exciting, but who 
knows?), use `pipx`, `uv` or something similar:

```bash
pipx install gitignore_lib
```

## Basic usage

Just open a `.gitignore` file and use the resulting object to match paths 
against the rules. For example:

```python
from gitignore import load # it also offers loads(), dump() and dumps()

ignore = load(".gitignore", base="/path/to/repo")
ignore("some/path/to/file.txt") # True, if the file is ignored
```

The ignore object also provides methods for filesystem traversal. For instance,
the `walk()` method behaves similarly to `Path.walk()` from `pathlib`:

```python
for dirpath, dirnames, filenames  in ignore.walk("/path/to/repo"):
    for file in filenames:
        print(dirpath / file) # non-ignored files only!
```

If you want to learn more, check the [documentation](https://gitignore-lib.readthedocs.io/en/latest/).