MIT License

项目介绍

mherrmann/gitignore_parser 是一个托管在 GitHub 上的开源项目,主要使用 Python 编写,采用 MIT License 许可证,目前获得 222 个 Star、46 次 Fork。

仓库全名
mherrmann/gitignore_parser
开源许可证
MIT License
Star 数
222
Fork 数
46
未关闭 Issue
10

README 摘要

gitignoreparser A spec-compliant gitignore parser for Python Installation pip install gitignoreparser Usage Suppose /home/michael/project/.gitignore contains the following: pycache/ .py[cod] Then: from gitignoreparser import parsegitignore matches = parsegitignore('/home/michael/project/.gitignore') matches('/home/michael/project/main.py') False matches('/home/michael/project/main.pyc') True…

完整内容见 GitHub 原始 README 或本页 。

常见问题

gitignore_parser 用什么语言开发?

主要使用 Python 编写,采用 MIT License 许可证,目前有 222 个 Star。

gitignore_parser 可以免费商用吗?

仓库采用 MIT License 许可证,可免费使用与修改,商业使用请遵守许可证条款(例如保留版权声明与许可声明)。

如何获取 gitignore_parser 的源码?

可以直接克隆仓库:git clone https://github.com/mherrmann/gitignore_parser.git,默认分支为 master;安装与运行步骤见仓库 README。

gitignore_parser 最近还在维护吗?

仓库最近一次更新为 2025年8月25日,当前有 10 个未关闭 Issue;Star 数为 222,可作为社区活跃度的参考。

关于

A spec-compliant gitignore parser for Python 3.5+

描述取自 GitHub 官方 API,中文内容由 GitRead 中文社区 编辑团队整理。

简要分析

热度分
317
价值分
146
活跃状态
活跃

语言占比

Python

README

gitignore_parser

CI PyPI version

A spec-compliant gitignore parser for Python

Installation

pip install gitignore_parser

Usage

Suppose /home/michael/project/.gitignore contains the following:

__pycache__/
*.py[cod]

Then:

>>> from gitignore_parser import parse_gitignore
>>> matches = parse_gitignore('/home/michael/project/.gitignore')
>>> matches('/home/michael/project/main.py')
False
>>> matches('/home/michael/project/main.pyc')
True
>>> matches('/home/michael/project/dir/main.pyc')
True
>>> matches('/home/michael/project/__pycache__')
True

Alternatively, you can use the parse_gitignore_str function:

>>> from gitignore_parser import parse_gitignore_str
>>> matches = parse_gitignore_str(
    '__pycache__/\n*.py[cod]', base_dir='/home/michael/project')
>>> matches('/home/michael/project/main.py')
False
>>> matches('/home/michael/project/main.pyc')
True

Motivation

I couldn’t find a good library for doing the above on PyPI. There are several other libraries, but they don’t seem to support all features, be it the square brackets in *.py[cod] or top-level paths /....

Contributing

I’m very open to merging PRs. But before you start working on one, please read through my guidelines for PRs. It will save us both time and unnecessary effort.

Attribution

The implementation is based on https://github.com/snark/ignorance/ by Steve Cook.

评论

暂无评论