Bash style brace expander.
Project description
Bracex
Bracex is a brace expanding library (à la Bash) for Python. Brace expanding is used to generate arbitrary strings.
$ echo {{a,b},c}d
ad bd cd
Bracex adds this ability to Python:
>>> bracex.expand(r'file-{{a,b},c}d.txt')
['file-ad.txt', 'file-bd.txt', 'file-cd.txt']
and as a command:
$ python3 -m bracex -0 "base/{a,b}/{1..2}" | xargs -0 mkdir -p
$ tree base/
base/
├── a
│ ├── 1
│ └── 2
└── b
├── 1
└── 2
-
Why Bracex over other solutions?
Bracex actually follows pretty closely to how Bash processes braces. It is not a 1:1 implementation of how Bash handles braces, but generally, it follows very closely. Almost all of the test cases are run through Bash first, then our implementation is compared against the results Bash gives. There are a few cases where we have purposely deviated. For instance, we are not handling Bash's command line inputs, so we are not giving special meaning to back ticks and quotes at this time.
On the command line Bracex can handle more expansions than Bash itself.
Install
$ pip install bracex
Documentation
Documentation is found here: https://facelessuser.github.io/bracex/.
License
MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file bracex-2.5.post1.tar.gz
.
File metadata
- Download URL: bracex-2.5.post1.tar.gz
- Upload date:
- Size: 26.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 12c50952415bfa773d2d9ccb8e79651b8cdb1f31a42f6091b804f6ba2b4a66b6 |
|
MD5 | c003aa94ba86a3b7785a228d050e386c |
|
BLAKE2b-256 | d66c57418c4404cd22fe6275b8301ca2b46a8cdaa8157938017a9ae0b3edf363 |
File details
Details for the file bracex-2.5.post1-py3-none-any.whl
.
File metadata
- Download URL: bracex-2.5.post1-py3-none-any.whl
- Upload date:
- Size: 11.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 13e5732fec27828d6af308628285ad358047cec36801598368cb28bc631dbaf6 |
|
MD5 | 48e2fe45e48298fbf48b81b7487231ab |
|
BLAKE2b-256 | 4b028db98cdc1a58e0abd6716d5e63244658e6e63513c65f469f34b6f1053fd0 |