Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gitignore_lib-0.1.1.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gitignore_lib-0.1.1-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

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

Hashes for gitignore_lib-0.1.1.tar.gz
Algorithm Hash digest
SHA256 6ed9c1b6e45b989f9c6857064012f2463cf158f9d4e60c2cce5ac2f5f1ba3021
MD5 b476898afd54c8abc730c0ceb788120b
BLAKE2b-256 2740bb91bc8af9eda702ec80b2b8824d6b2f6aaed73c944469ed46ff9b78dd58

See more details on using hashes here.

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

Hashes for gitignore_lib-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 46bc645b92c6dba202cf0f2b1f39a2bd5f711e9d9c4af9e47a95eeeda53eb50b
MD5 bdbbeacd70b35d708fd510207cff5993
BLAKE2b-256 e63fd9c04e2ff37a0c02af5293ab303201231d1b00f5c48dbd224f2a31d6880b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page