Skip to main content

Filter a list of strings and/or paths based on include and exclude patterns.

Project description

younotyou

Filter a list of strings and/or paths based on include and exclude patterns.

Installation

Install with:

pip install younotyou

Convenient one stop shop to include and exclude strings using glob style pattern matching.

Usage

Patterns can be literals or glob style wildcard strings.
Exclusion patterns override include patterns, i.e. if an item matches an include pattern but also matches an exclude pattern, it will be excluded.

>>> from younotyou import younotyou
>>> strings = ["thispattern", "aPaTtErN", "mypatterns"]
>>> younotyou(strings, ["*pattern"])
['thispattern']
>>> younotyou(strings, ["*pattern*"])
['thispattern', 'mypatterns']
>>> younotyou(strings, ["*pattern*"], case_sensitive=False)
['thispattern', 'aPaTtErN', 'mypatterns']
>>> younotyou(strings, ["*pattern*"], ["my*", "*is*"], case_sensitive=False)
['aPaTtErN']
>>> younotyou(strings, exclude_patterns=["*PaT*"])
['thispattern', 'mypatterns']
>>> younotyou(strings, exclude_patterns=["*PaT*"], case_sensitive=False)
[]
>>> younotyou(strings, include_patterns=["*PaT*"], exclude_patterns=["*PaT*"], case_sensitive=False)
[]

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

younotyou-0.1.1.tar.gz (2.9 kB view hashes)

Uploaded Source

Built Distribution

younotyou-0.1.1-py3-none-any.whl (3.7 kB view hashes)

Uploaded Python 3

Supported by

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