Registry / devops / bracex

bracex

JSON →
library2.6pypypi✓ verified 51d ago

Bracex is a Python library that provides Bash-style brace expansion, enabling the generation of arbitrary strings from patterns. It closely emulates Bash's brace processing, supporting comma-separated lists, numerical and alphabetical sequences (ranges), and optional step increments. The library is actively maintained, with version 2.6 being the latest, and releases occur regularly to ensure compatibility with newer Python versions and address minor fixes.

devopsserialization
pip install bracex
Install & Compatibility
Where this runs
tested against v2.6 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.925 runs
installs and imports cleanly · install 0.0s · import 0.015s · 17.8MB
glibc
py 3.103.925 runs
installs and imports cleanly · install 1.5s · import 0.014s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

expand
import bracex expanded_list = bracex.expand('file-{a,b}.txt')
from bracex import expand # Less common, but still correct if preferred for brevity.
The most common usage is to import the `bracex` module and call its functions directly.
iexpand
import bracex expanded_generator = bracex.iexpand('file-{1..3}.jpg')
`iexpand` returns a generator for memory-efficient iteration, useful for very large expansions.

Demonstrates basic brace expansion for lists, nested patterns, numerical and alphabetical sequences, and the generator-based iteration using `iexpand`.

import bracex # Basic list expansion print(bracex.expand(r'file-{a,b,c}.txt')) # Nested brace expansion print(bracex.expand(r'path/to/{{foo,bar},baz}/file.txt')) # Numerical sequence (range) expansion print(bracex.expand(r'image{00..02}.png')) # Numerical sequence with step print(bracex.expand(r'item{1..10..3}.log')) # Alphabetic sequence print(bracex.expand(r'letter{A..D}.md')) # Using the generator version for item in bracex.iexpand(r'data-{1..5}.csv'): print(item)
Debug
Known issues
breakingBracex has progressively dropped support for older Python versions. Version 2.6 (current) requires Python 3.9 or higher. Previous versions dropped support for Python 3.8 (in 2.6), 3.7 (in 2.4), 3.6 (in 2.3), and 3.5 (in 2.1.0).
fix
Upgrade your Python environment to 3.9 or newer before upgrading to bracex 2.6. Always check the `requires_python` field on PyPI for the desired `bracex` version.
affects: <2.6 (for Python 3.8), <2.4 (for Python 3.7), <2.3 (for Python 3.6), <2.1.0 (for Python 3.5)
gotchaThe `expand()` and `iexpand()` functions include a `limit` parameter (defaulting to 1000) to prevent excessively large expansions, which could lead to performance issues or 'brace bombs'. If an expansion exceeds this limit, an error is raised.
fix
For very large or potentially unbounded expansions, consider increasing the `limit` parameter (e.g., `bracex.expand(pattern, limit=5000)`) or setting `limit=0` to disable the limit entirely if you are certain of the pattern's safety and have sufficient memory. Using `iexpand()` can also help manage memory for large results.
affects: All versions with `limit` parameter (>=2.1.1)
gotchaWhile `bracex` closely mimics Bash's brace expansion, it is not a 1:1 implementation. It may deviate in certain edge cases, particularly regarding how Bash handles command-line inputs (e.g., backticks and quotes).
fix
If migrating complex Bash scripts, thoroughly test patterns in `bracex` that rely on specific Bash shell behaviors beyond simple brace expansion. Refer to the official documentation for noted deviations.
affects: All versions
deprecatedThe build backend for `bracex` switched from Setuptools to Hatch in version 2.3. While this primarily affects maintainers and packagers, it's a significant internal change.
fix
Users consuming `bracex` via `pip install` are generally unaffected. If you are involved in packaging or contributing, be aware of the updated build system requirements and configuration (e.g., `pyproject.toml`).
affects: <2.3
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'bracex'
The 'bracex' library is not installed in your Python environment, or the Python interpreter cannot find it.
fix
Install the library using pip: `pip install bracex`
bracex.BraceExpansionError: Brace expansion exceeded the limit of 1000 items.
The brace expansion pattern you provided generates more strings than the default `limit` of 1000 allowed by `bracex.expand()` or `bracex.iexpand()` to prevent 'brace bombs' or excessive memory usage.
fix
Increase the `limit` parameter in the `expand()` or `iexpand()` function call, or set `limit=0` to disable it if you are certain of the pattern's safety and have sufficient memory. Using `iexpand()` can also help manage memory for large results.
```python
import bracex
# To increase the limit
expanded_list = bracex.expand('{1..5000}', limit=5000)
# To disable the limit (use with caution for unbounded expansions)
expanded_list = bracex.expand('{1..infinity}', limit=0)
```
ERROR: Package 'bracex' requires Python '>=3.9' but the running Python is X.Y.Z
You are attempting to install or run `bracex` version 2.6 (or newer) with a Python version older than 3.9, which is not supported by this version of the library.
fix
Upgrade your Python environment to version 3.9 or newer. Alternatively, if feasible, install an older version of `bracex` that supports your current Python version (e.g., `pip install bracex==2.5` for Python 3.8, if available, but upgrading Python is recommended).
Upgrade
Version history
2.6latest on PyPI
Audit
Dependencies

No dependency data recorded yet.

Agent activity
65 hits · last 30 days
node
8
seranking-bot
4
ahrefsbot
2
amazonbot
1
bytedance
1
Resources