Skip to main content

Bash style brace expander.

Project description

Donate via PayPal [![Discord][discord-image]][discord-link] Build 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-2.5.tar.gz (26.6 kB view details)

Uploaded Source

Built Distribution

bracex-2.5-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: bracex-2.5.tar.gz
  • Upload date:
  • Size: 26.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for bracex-2.5.tar.gz
Algorithm Hash digest
SHA256 0725da5045e8d37ea9592ab3614d8b561e22c3c5fde3964699be672e072ab611
MD5 abeb7b5c5fd8b022cb642a1150ef8f4e
BLAKE2b-256 acf1ac657fd234f4ee61da9d90f2bae7d6078074de2f97cb911743faa8d10a91

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: bracex-2.5-py3-none-any.whl
  • Upload date:
  • Size: 11.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for bracex-2.5-py3-none-any.whl
Algorithm Hash digest
SHA256 d2fcf4b606a82ac325471affe1706dd9bbaa3536c91ef86a31f6b766f3dad1d0
MD5 9f833464ddb817e45d983e4459d542c2
BLAKE2b-256 054f54d324c35221c027ca77e9aae418f525003bd0cc2613eea162a1246b5a92

See more details on using hashes here.

Provenance

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