senkawa
Glob with Bash-style brace expansion.
[!NOTE] This package is highly influenced by trendels/braceexpand.
Installation
pip install senkawa
Usage
>>> import senkawa
# With glob
>>> list(senkawa.glob("*.{md,toml}"))
["README.md", "pyproject.toml"]
>>> list(senkawa.glob("tests/fixtures/{1..3}.txt"))
["tests/fixtures/1.txt", "tests/fixtures/2.txt", "tests/fixtures/3.txt"]
# Integer range
>>> list(senkawa.brace_expand('item{1..3}'))
['item1', 'item2', 'item3']
# Character range
>>> list(senkawa.brace_expand('{a..c}'))
['a', 'b', 'c']
# Sequence
>>> list(senkawa.brace_expand('index.html{,.backup}'))
['index.html', 'index.html.backup']
# Nested patterns
>>> list(senkawa.brace_expand('python{2.{5..7},3.{2,3}}'))
['python2.5', 'python2.6', 'python2.7', 'python3.2', 'python3.3']
# Prefixing an integer with zero causes all numbers to be padded to
# the same width.
>>> list(senkawa.brace_expand('{07..10}'))
['07', '08', '09', '10']
# An optional increment can be specified for ranges.
>>> list(senkawa.brace_expand('{a..g..2}'))
['a', 'c', 'e', 'g']
# Ranges can go in both directions.
>>> list(senkawa.brace_expand('{4..1}'))
['4', '3', '2', '1']
# Numbers can be negative
>>> list(senkawa.brace_expand('{2..-1}'))
['2', '1', '0', '-1']
# Unbalanced braces raise an exception.
>>> list(senkawa.brace_expand('{1{2,3}'))
Traceback (most recent call last):
...
senkawa.errors.UnbalancedBracesError: Unbalanced braces: '{1{2,3}'
# By default, the backslash is the escape character.
>>> list(senakwa.brace_expand(r'{1\{2,3}'))
['1{2', '3']
# Setting 'escape' to False disables backslash escaping.
>>> list(senkawa.brace_expand(r'\{1,2}', escape=False))
['\\1', '\\2']
Metadata
Release files for senkawa 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| senkawa-0.1.0.tar.gz | 4.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| senkawa-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.9 kB
Release files / senkawa-0.1.0.tar.gz
| Download URL | senkawa-0.1.0.tar.gz |
|---|---|
| Size | 4.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7eea640b52cd11cea9b7cb981a5e17bd9177912942528871bf01d79889d63321
|
|
BLAKE2b-256 checksum How to use checksums |
d10bdd5d8c9faef336c811fc1d856f809aec911f4bb19e878c89671a1c72d414
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.10.12 Linux/6.5.0-1022-azure
|
Release files / senkawa-0.1.0-py3-none-any.whl
| Download URL | senkawa-0.1.0-py3-none-any.whl |
|---|---|
| Size | 6.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
60930e01f0a24997748b51db031b7c12010e71421624afbcab5b2cbf82db5516
|
|
BLAKE2b-256 checksum How to use checksums |
3d93741cc7bb70b3e7b7bd3a76a9601dd6ad5b4d041fb73021b44788898aceb1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.10.12 Linux/6.5.0-1022-azure
|