跳转到主要内容

匹配路径与glob

项目描述

安装 | 用法 | 测试 | 许可证

globmatch - 匹配路径与glob

codecov.io

globmatch 提供了在Python中匹配路径与一个或多个glob模式的功能。这与标准库中的 glob 模块不同,后者将glob与系统上的文件树进行匹配。 globmatch 完全不与文件系统交互,而依赖于通用匹配。它也与标准库中的 fnmatch 模块不同,因为它接受双星号(**)元素,该元素匹配零个或多个目录。此外,fnmatch 中的星号元素(*)也会跨路径分隔符进行匹配。在 globmatch 中,星号元素匹配当前路径元素(目录/文件名)的零个或多个字符。

安装

使用pip安装globmatch

pip install globmatch

或进行开发安装

pip install -e git+https://github.com/vidartf/globmatch#egg=globmatch

用法

from globmatch import glob_match

# Some paths that match (returns True):
glob_match('.git/gitconfig/', ['.git'])
glob_match('foo/config', ['**/config'])
glob_match('foo/config/bar', ['**/config'])
glob_match('.git/gitconfig/', ['.git', '**/config'])
glob_match('foo/config/bar', ['.git', '**/config'])
glob_match('/.git/gitconfig/', ['**/.git'])

# Some paths that do not match (returns False):
glob_match('/.git/gitconfig/', ['.git'])   # Needs ** to match subdir of root dir
glob_match('foo/node_modules', ['node_modules'])   # Will not match subdir without preceding **

测试

安装带有测试需求的开发安装

pip install -e globmatch[test]

要在本地运行Python测试,请在命令行中输入:pytest

安装 codecov浏览器扩展 以在github源浏览器中查看测试覆盖率。

许可证

所有代码均按照修订版BSD许可证的条款进行许可。

资源

项目详情


下载文件

下载适用于您平台的文件。如果您不确定选择哪个,请了解更多关于 安装包 的信息。

源代码分发

globmatch-2.0.0.tar.gz (10.2 kB 查看哈希值)

上传时间 源代码

构建分发

globmatch-2.0.0-py2.py3-none-any.whl (7.7 kB 查看哈希值)

上传时间 Python 2 Python 3

由以下组织支持