Skip to content

Enhanced fnmatch with grouping regex and path transformation

License

Notifications You must be signed in to change notification settings

pykit3/k3fnmatch

Repository files navigation

k3fnmatch

Action-CI Documentation Status Package

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

>>> 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

About

Enhanced fnmatch with grouping regex and path transformation

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •