Matching paths against globs
Project description
Installation | Usage | Testing | License
globmatch - Matching paths against globs
globmatch provides functions for matching a path against one ore more glob patterns in Python.
This differs from the glob module of the standard library, which matches a glob against the
file-tree on your system. globmatch does not interact with the filesystem at all, but relies on
generic matching. It also differs from the fnmatch module of the standard library in that it
accepts the double star (**) element, which matches zero or more directories. Additionally, the
star element (*) in fnmatch will also match across path separators. In globmatch the
star element matches zero or more characters of the current path element (directory/file name).
Installation
Install globmatch with pip:
pip install globmatch
or for a development install:
pip install -e git+https://github.com/vidartf/globmatch#egg=globmatch
Usage
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 **
Testing
Install the develop install with test requirements:
pip install -e globmatch[test]
To run Python tests locally, enter on the command line: pytest
Install the codecov browser extension to view test coverage in the source browser on github.
License
All code is licensed under the terms of the revised BSD license.
Resources
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file globmatch-2.0.0.tar.gz.
File metadata
- Download URL: globmatch-2.0.0.tar.gz
- Upload date:
- Size: 10.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f02e51158f4c6112a3ea8c691f7ff6510791e9caf10fc4e62cc8d013d224bf9d
|
|
| MD5 |
eef5ae23f789d625c2452d4e5378e297
|
|
| BLAKE2b-256 |
598f4e01e334765a425a200fdbe5568894e42d43f77994b4c86caa23927235a5
|
File details
Details for the file globmatch-2.0.0-py2.py3-none-any.whl.
File metadata
- Download URL: globmatch-2.0.0-py2.py3-none-any.whl
- Upload date:
- Size: 7.7 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7aef5c66b112f1fcbbacae029e426555e31c7e7556c8542f35931db9b1a9b1d3
|
|
| MD5 |
5b0d7e1f1a34d5437ff0b3ea08106f8c
|
|
| BLAKE2b-256 |
67f1a50c00bd5d36b5f57a20c81fa37ee0ed095d0639298c1135913c25a1b0b8
|