Metadata-Version: 2.4
Name: k3fnmatch
Version: 0.1.1
Summary: Enhanced fnmatch with grouping regex and path transformation
Author-email: Zhang Yanpo <drdr.xp@gmail.com>
License: MIT
Project-URL: Homepage, https://github.com/pykit3/k3fnmatch
Project-URL: Documentation, https://k3fnmatch.readthedocs.io
Keywords: fnmatch,glob,pattern,path,regex,wildcard
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Topic :: Software Development :: Libraries
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: ruff; extra == "dev"
Requires-Dist: coverage; extra == "dev"
Provides-Extra: publish
Requires-Dist: build; extra == "publish"
Requires-Dist: twine; extra == "publish"
Requires-Dist: pk3; extra == "publish"
Provides-Extra: docs
Requires-Dist: mkdocs>=1.5; extra == "docs"
Requires-Dist: mkdocs-material>=9.0; extra == "docs"
Requires-Dist: mkdocstrings[python]>=0.24; extra == "docs"
Dynamic: license-file

# k3fnmatch

[![Action-CI](https://github.com/pykit3/k3fnmatch/actions/workflows/python-package.yml/badge.svg)](https://github.com/pykit3/k3fnmatch/actions/workflows/python-package.yml)
[![Documentation Status](https://readthedocs.org/projects/k3fnmatch/badge/?version=stable)](https://k3fnmatch.readthedocs.io/en/stable/?badge=stable)
[![Package](https://img.shields.io/pypi/pyversions/k3fnmatch)](https://pypi.org/project/k3fnmatch)

Enhanced fnmatch with grouping regex and path transformation

k3fnmatch is a component of [pykit3] project: a python3 toolkit set.


Enhanced fnmatch with grouping regex and path transformation.

Provides:
- translate(): Enhanced fnmatch.translate() with grouping and ** support
- fnmap(): Transform paths using source and destination patterns

Examples:
    >>> import re
    >>> pattern = translate("**/*.md")
    >>> m = re.match(pattern, "foo/bar/doc.md")
    >>> len(m.groups()) >= 3
    True

    >>> fnmap("foo/bar.md", "**/*.md", "**/*-cn.md")
    'foo/bar-cn.md'



# Install

```
pip install k3fnmatch
```

# Synopsis

```python
>>> import re
>>> pattern = translate("**/*.md")
>>> m = re.match(pattern, "foo/bar/doc.md")
>>> len(m.groups()) >= 3
True
>>> fnmap("foo/bar.md", "**/*.md", "**/*-cn.md")
'foo/bar-cn.md'
```

#   Author

Zhang Yanpo (张炎泼) <drdr.xp@gmail.com>

#   Copyright and License

The MIT License (MIT)

Copyright (c) 2015 Zhang Yanpo (张炎泼) <drdr.xp@gmail.com>


[pykit3]: https://github.com/pykit3
