Skip to main content

Bash style brace expander.

Project description

Donate via PayPal Coverage Status PyPI Version PyPI - Python Version License

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


Download files

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

Source Distribution

bracex-3.0.1.tar.gz (44.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bracex-3.0.1-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

Details for the file bracex-3.0.1.tar.gz.

File metadata

  • Download URL: bracex-3.0.1.tar.gz
  • Upload date:
  • Size: 44.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for bracex-3.0.1.tar.gz
Algorithm Hash digest
SHA256 4e38e32392e4a4780fe15d644bfc7c8514057cfc3861e060b11814ce829c25e4
MD5 6f3298f1c6859df408221d78af27b071
BLAKE2b-256 ac015f394b8bcd6e5b92f73130990960423bbb19711f906bd9fe9ea5557c667c

See more details on using hashes here.

Provenance

The following attestation bundles were made for bracex-3.0.1.tar.gz:

Publisher: deploy.yml on facelessuser/bracex

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file bracex-3.0.1-py3-none-any.whl.

File metadata

  • Download URL: bracex-3.0.1-py3-none-any.whl
  • Upload date:
  • Size: 11.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for bracex-3.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6523ad83aeb5098a4ee597cff0f964442ff74e460bd3fafaffab6a013ff2288c
MD5 2d9562478b94d51bb0fa65459f68e51c
BLAKE2b-256 b88f6f7273a7adb8d73fc8d21ede4376a3e475e52f98435c6007f69100dec8ca

See more details on using hashes here.

Provenance

The following attestation bundles were made for bracex-3.0.1-py3-none-any.whl:

Publisher: deploy.yml on facelessuser/bracex

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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