Gitignore-style路径匹配
项目描述
GitHub | PyPI | 文档 | 问题 | 变更日志
gitmatch 提供了 gitignore 样式的文件路径模式匹配。只需传入一系列 gitignore 模式,即可返回一个用于测试给定相对路径是否匹配这些模式的对象。
安装
gitmatch 需要 Python 3.8 或更高版本。只需使用 Python 3 的 pip 安装即可(您有 pip,对吧?)
python3 -m pip install gitmatch
示例
基本用法
>>> import gitmatch
>>> gi = gitmatch.compile(["foo", "!bar", "*.dir/"])
>>> bool(gi.match("foo"))
True
>>> bool(gi.match("bar"))
False
>>> bool(gi.match("quux"))
False
>>> bool(gi.match("foo/quux"))
True
>>> bool(gi.match("foo/bar"))
True
>>> bool(gi.match("bar/foo"))
True
>>> bool(gi.match("bar/quux"))
False
>>> bool(gi.match("foo.dir"))
False
>>> bool(gi.match("foo.dir/"))
True
查看匹配的模式
>>> m1 = gi.match("foo/bar")
>>> m1 is None
False
>>> bool(m1)
True
>>> m1.pattern
'foo'
>>> m1.path
'foo'
>>> m2 = gi.match("bar")
>>> m2 is None
False
>>> bool(m2)
False
>>> m2.pattern
'!bar'
>>> m2.pattern_obj.negative
True
>>> m3 = gi.match("quux")
>>> m3 is None
True
项目详情
下载文件
下载适合您平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。
源分发
         gitmatch-0.2.0.tar.gz  (16.2 kB 查看哈希值)
      
    构建分发
         gitmatch-0.2.0-py3-none-any.whl  (8.0 kB 查看哈希值)
      
    
    
       关闭
    
      
        
    
    
  
gitmatch-0.2.0.tar.gz的哈希值
| 算法 | 哈希摘要 | |
|---|---|---|
| SHA256 | b9e1b4b9336f5013b30a9929fdc037a68e3971e2c30545d8ba50a4e81931a0a5 | |
| MD5 | 6c6ea66a7c420955cdd328eae1e33184 | |
| BLAKE2b-256 | c4033b7dc756867ccef54f99c72b96b431c72c9161d80851eebab8ac247ef32b | 
    
       关闭
    
      
        
    
    
  
gitmatch-0.2.0-py3-none-any.whl的哈希值
| 算法 | 哈希摘要 | |
|---|---|---|
| SHA256 | 9c67d74b9dd32e06ffd0a079cffdcc764e9d8a0281b981487ed21699c030e1a0 | |
| MD5 | 7fbc60865d80dfedb8e9fa88621ab72e | |
| BLAKE2b-256 | 288305bd9481ccd80f497936e2587ee846106af862a7dae8a52116b35e1d4082 |