Registry / globmatch

globmatch

JSON →
library2.0.0pypypi✓ verified 87d ago

globmatch provides functions for matching a path against one or more glob patterns in Python. Unlike the standard library's `glob` module, it does not interact with the filesystem, focusing solely on generic string matching. It extends `fnmatch` capabilities by supporting the `**` pattern for matching zero or more directories. The current version is 2.0.0, with releases historically being infrequent but demonstrating active maintenance.

pip install globmatch
INSTALL
IMPORT
SIG · GLOBMATCH
G
globmatch
pythonv2.0.0
Install
1.5s avg
Import
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2.0.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 17.8MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 1.5s · import 0.000s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

glob_match
from globmatch import glob_match

Demonstrates basic usage of `glob_match` with single and multiple patterns, including recursive matching with `**` and handling of dotfiles. The `match_all=True` parameter ensures all patterns are considered, enabling exclusion patterns.

from globmatch import glob_match # Basic matching print(glob_match('foo/config', ['**/config'])) # Expected: True print(glob_match('foo/bar/config', ['**/config'])) # Expected: True print(glob_match('foo/config/bar', ['foo/config'])) # Expected: False (needs /** for sub-elements) # Matching dotfiles print(glob_match('.git/gitconfig', ['.git/**'])) # Expected: True # Multiple patterns patterns = ['!.git', '**/config'] # Match config, but not if it's in .git print(glob_match('.git/config', patterns, match_all=True)) # Expected: False print(glob_match('myproject/config', patterns, match_all=True)) # Expected: True
Debug
Known issues
breakingVersion 2.0.0 introduced fixes for the `**` pattern on Windows and for matching dotfiles. Code relying on previous, potentially incorrect, behavior in these areas may break.
fix
Upgrade to `globmatch` 2.0.0 or higher. Thoroughly test existing glob patterns, especially those involving `**` on Windows paths or patterns targeting dotfiles, to ensure expected behavior.
affects: <2.0.0
gotchaThe `*` wildcard in `globmatch` matches zero or more characters within a single path segment only (i.e., it does not cross path separators like `/` or `\`). For matching across zero or more directories recursively, you must explicitly use the `**` wildcard.
fix
If you intend to match files or directories nested deeply, use `**` (e.g., `some/path/**/*.txt`) instead of `*` (e.g., `some/path/*.txt`) for the recursive part.
affects: All versions
gotcha`globmatch` is purely a string pattern matching library and does not interact with the filesystem. It cannot be used to find or list actual files on disk. Its purpose is to test if a given string path matches a glob pattern.
fix
If you need to find files on the filesystem that match a glob pattern, use Python's standard `glob` module (`glob.glob` or `pathlib.Path.glob`), ensuring `recursive=True` is set for `**` patterns.
affects: All versions
Errors
Common errors & fixes
glob_match('path/to/file', ['path/*/file']) returns False when it should match 'path/subdir/file'.
The `*` wildcard only matches within a single path component. It does not cross directory boundaries.
fix
Use the `**` wildcard for recursive matching across directories. Change the pattern to `['path/**/file']`.
My patterns work in bash/zsh but globmatch doesn't find files.
The `globmatch` library *only* matches strings against patterns; it does not list or interact with files on the filesystem. This is a common confusion with shell globbing or Python's `glob` module.
fix
If your goal is to find actual files on the filesystem, use Python's built-in `glob.glob()` or `pathlib.Path.glob()` functions. `globmatch` is for abstract path string matching.
`glob_match('foo/.config', ['.config'])` returns `False` or inconsistent results on Windows.
Older versions of `globmatch` (prior to 2.0.0) had known issues with `**` patterns on Windows and inconsistent matching of dotfiles.
fix
Ensure you are using `globmatch` version `2.0.0` or newer. This version specifically addressed these compatibility and matching issues.
Upgrade
Version history
2.0.0latest on PyPI · released Jan 7, 2021
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
globmatch — pip install globmatch · libregistry