匹配路径与glob
项目描述
globmatch - 匹配路径与glob
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 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | f02e51158f4c6112a3ea8c691f7ff6510791e9caf10fc4e62cc8d013d224bf9d |
|
MD5 | eef5ae23f789d625c2452d4e5378e297 |
|
BLAKE2b-256 | 598f4e01e334765a425a200fdbe5568894e42d43f77994b4c86caa23927235a5 |
关闭
globmatch-2.0.0-py2.py3-none-any.whl 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 7aef5c66b112f1fcbbacae029e426555e31c7e7556c8542f35931db9b1a9b1d3 |
|
MD5 | 5b0d7e1f1a34d5437ff0b3ea08106f8c |
|
BLAKE2b-256 | 67f1a50c00bd5d36b5f57a20c81fa37ee0ed095d0639298c1135913c25a1b0b8 |