Simple tool to parse and use .gitignore files.
Project description
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:
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:
pipx install gitignore_lib
Basic usage
Just open a .gitignore file and use the resulting object to match paths
against the rules. For example:
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:
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gitignore_lib-0.1.1.tar.gz.
File metadata
- Download URL: gitignore_lib-0.1.1.tar.gz
- Upload date:
- Size: 6.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6ed9c1b6e45b989f9c6857064012f2463cf158f9d4e60c2cce5ac2f5f1ba3021
|
|
| MD5 |
b476898afd54c8abc730c0ceb788120b
|
|
| BLAKE2b-256 |
2740bb91bc8af9eda702ec80b2b8824d6b2f6aaed73c944469ed46ff9b78dd58
|
File details
Details for the file gitignore_lib-0.1.1-py3-none-any.whl.
File metadata
- Download URL: gitignore_lib-0.1.1-py3-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
46bc645b92c6dba202cf0f2b1f39a2bd5f711e9d9c4af9e47a95eeeda53eb50b
|
|
| MD5 |
bdbbeacd70b35d708fd510207cff5993
|
|
| BLAKE2b-256 |
e63fd9c04e2ff37a0c02af5293ab303201231d1b00f5c48dbd224f2a31d6880b
|