upload existing project

This commit is contained in:
2026-04-06 17:28:26 +02:00
parent f01c408c87
commit 6bd8fc08bc
12 changed files with 1402 additions and 1 deletions

View File

@@ -1,2 +1,64 @@
# kpmatch
# 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.
<dl>
<dt>Parameters</dt>
<dd>
<strong>path</strong> — A relative or absolute file path.<br/>
<strong>pattern</strong> — A path pattern (see above for the syntax of patterns).
</dd>
<dt>Returns</dt>
<dd>True if the path matches the pattern.</dd>
</dl>
```
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.
```python
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.
```python
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.