Skip to main content

wildcard

Project description

wildcard

This library is a fork of fnmatch (https://docs.python.org/2/library/fnmatch.html) to implement **

PypiDownloads

All documentation is identical to fnmatch except * , * is now ** and * only affects the particular directory

https://docs.python.org/2/library/fnmatch.html

Install

pip install pywildcard

Link pypi: https://pypi.python.org/pypi/pywildcard

Example

import pywildcard
dirs = ['hello/world.py', 'hello/world.pyc', 'hello/world/other/folder/example.py']
pywildcard.filter(dirs, 'hello/*')
#  ['hello/world.py', 'hello/world.pyc']

pywildcard.filter(dirs, 'hello/*.py')
# ['hello/world.py']

pywildcard.filter(dirs, 'hello/**')
# ['hello/world.py', 'hello/world.pyc', 'hello/world/other/folder/example.py']

pywildcard.filter(dirs, 'hello/**.py')
# ['hello/world.py', 'hello/world/other/folder/example.py']

Diffs fnmatch & pywildcard

fnmatch

import re
import fnmatch

urls = ['example/l1/l2/test3-1.py',
        'example/l1/test2-1.py',
        'example/l1/test2-2.py',
        'example/l1/l2/l3/test4-1.py']

regex = fnmatch.translate('example/*')
# 'example\\/.*\\Z(?ms)'
re.findall(regex, "\n".join(urls))
# return ['example/l1/l2/test3-1.py\nexample/l1/test2-1.py\nexample/l1/test2-2.py\nexample/l1/l2/l3/test4-1.py']

pywildcard

import re
import pywildcard

urls = ['example/l1/l2/test3-1.py',
        'example/l1/test2-1.py',
        'example/l1/test2-2.py',
        'example/l1/l2/l3/test4-1.py']

regex = pywildcard.translate('example/**')
# ''example\\/.*?$(?ms)
re.findall(regex, "\n".join(urls))
# return ['example/l1/l2/test3-1.py',
#         'example/l1/test2-1.py',
#         'example/l1/test2-2.py',
#         'example/l1/l2/l3/test4-1.py']

CHANGELOG

1.0.8 (2015-11-26)

  • update README.md

1.0.7 (2015-11-25)

  • Add documentation

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pywildcard-1.0.8.tar.gz (3.5 kB view details)

Uploaded Source

File details

Details for the file pywildcard-1.0.8.tar.gz.

File metadata

  • Download URL: pywildcard-1.0.8.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pywildcard-1.0.8.tar.gz
Algorithm Hash digest
SHA256 49cd97f7514bf15a404272cb4003019b00f93ed2336fd8e7347c46559c49093c
MD5 5a0757229fdb316fcf026b51b6a27c33
BLAKE2b-256 a5ca1e9664015502a1a35f52d4ee60046e9819f78452378403e6066d96262ea7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page