Pathmatch
Python implementation of git’s wildmatch and POSIX.1-2008 fnmatch.
The aim of this package is to provide a file matching module complying with the POSIX standard and allow compatibility with git.
Example
from pathmatch import wildmatch
# Pattern matching auto-generated test files (extension .pyc, .pyo or .pyd inside tests/)
pattern = u'tests/**/*.py[cod]'
# Match single files:
wildmatch.match(pattern, u'tests/auto.pyc') # True
wildmatch.match(pattern, u'auto.pyc') # False
# Filter a collection:
files = [
u'tests/deep/auto.pyd',
u'tests/module.py',
u'package/auto.pyc',
u'tests/auto.pyo'
]
list(wildmatch.filter(pattern, files)) # [u'tests/deep/auto.pyd', u'tests/auto.pyo']
# Compile a pattern
compiled = wildmatch.WildmatchPattern(pattern)
compiled.match(u'tests/') # False
Features
wildmatch support
Currently, the following wildmatch features are supported:
Wildstar ** operator and associated semantics (/ requires a literal match)
Literal matching
Question mark ? (any character) and asterisk * (any string) operators
Bracket expressions [abc] (character alternatives)
Bracket expression features:
Negation (supports both ^ and ! meta-characters)
Range expressions a-z
Collation Symbol [.ch.]
Equivalence classes syntax [=e=], but fallback to collation symbol semantics
Supports the path_name flag to exclude / (which requires a literal match)
See test_wildmatch.py for more details.
Limitations:
case_fold (case insensitive) option is not supported
period (require literal match for leading period) option is not supported
Negated bracket expression with multi-character collating elements are not supported
Character classes [:alpha:] for bracket expressions are not supported
Contributions are welcomed
fnmatch support
The dedicated fnmatch module is not yet configured (this should just be a subset of wildmatch).
Contributing
Tests
You can execute the tests with the following command:
python -m unittest discover -s . -p test*.py
References:
License
MIT License, Copyright (c) 2016 Charles Samborski
Metadata
Release files for pathmatch 0.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pathmatch-0.2.2.tar.gz | 24.5 kB | Without provenance | Details for pathmatch-0.2.2.tar.gz |
Release files / pathmatch-0.2.2.tar.gz
| Download URL | pathmatch-0.2.2.tar.gz |
|---|---|
| Size | 24.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ea020e5e20114b2587eba2c9f909a0b9aa449e55522ce80bfac7da0fe695984d
|
|
BLAKE2b-256 checksum How to use checksums |
ed987ef76707728a9f82c30917e807e0e6d5925c6f1b90913c8bef36f30795c0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2
|
Security for pathmatch 0.2.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.