admin 2e50f0a5bc
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 1s
Actualiser .gitea/workflows/demo.yaml
2026-04-07 21:38:25 +02:00
2026-04-06 17:28:26 +02:00
2026-04-06 17:28:26 +02:00
2026-04-06 17:28:26 +02:00
2026-04-06 17:14:17 +02:00
2026-04-06 17:28:26 +02:00
2026-04-06 17:28:26 +02:00
2026-04-06 17:28:26 +02:00

kpmatch - Path patterns

Pattern Syntax

Path patterns should always use forward slashes / between segments. The actual separator used when matching paths depends on the system.

A path segment containing two asterisks /**/ matches zero, one or more segments.

A single asterisk * matches zero, one or more characters except a path separator.

A question mark ? matches exactly one character unless it's a path separator.

Square brackets [ ] can match one of the characters between the brackets. If the first character is an exclamation point [! ], it will match one character that does NOT appear between the brackets.

Curly braces { , } can match one of the sub-expressions separated by commas.

API

Function kpmatch.kpmatch(path: str | PathLike[str], pattern: str) -> bool

Method kpmatch.Pattern.match(path: str | PathLike[str]) -> bool

Tests if a path matches a pattern.

Parameters
path — A relative or absolute file path.
pattern — A path pattern (see above for the syntax of patterns).
Returns
True if the path matches the pattern.
function kpmatch.specificity(pattern: str) -> float
property kpmatch.Pattern.specificity: bool

Computes the specificity of a pattern. The higher the number, the more specific it is. :param pattern: The path pattern to evaluate. :return: A positive integer.

def compile(pattern: str) -> Pattern

Compiles a pattern into a Pattern object that can be reused multiple times. :param pattern: The path pattern to compile.

def is_valid_pattern(pattern: str) -> bool

Verifies the syntax of a pattern. :param pattern: The path pattern to check. :return: True if the pattern is well-formed.

Description
No description provided
Readme MIT 95 KiB
Languages
Python 100%