| 1 |
Metadata-Version: 1.1 |
| 2 |
Name: braceexpand |
| 3 |
Version: 0.1.7 |
| 4 |
Summary: Bash-style brace expansion for Python |
| 5 |
Home-page: https://github.com/trendels/braceexpand |
| 6 |
Author: Stanis Trendelenburg |
| 7 |
Author-email: [email protected] |
| 8 |
License: MIT |
| 9 |
Description: Bash-style brace expansion for Python |
| 10 |
===================================== |
| 11 |
|
| 12 |
|build-status-img| |PyPI| |
| 13 |
|
| 14 |
Implements Brace Expansion as described in |
| 15 |
`bash(1) <http://man7.org/linux/man-pages/man1/bash.1.html#EXPANSION>`__, |
| 16 |
with the following limitations: |
| 17 |
|
| 18 |
- A pattern containing unbalanced braces will raise an |
| 19 |
``UnbalancedBracesError`` exception. In bash, unbalanced braces will |
| 20 |
either be partly expanded or ignored. |
| 21 |
|
| 22 |
- A mixed-case character range like ``'{Z..a}'`` or ``'{a..Z}'`` will |
| 23 |
not include the characters :literal:`[]^_\`` between ``Z`` and ``a``. |
| 24 |
|
| 25 |
``braceexpand`` is tested with Python 2.7, and 3.6+ |
| 26 |
|
| 27 |
Installation |
| 28 |
------------ |
| 29 |
|
| 30 |
Install the ``braceexpand`` package from pypi: |
| 31 |
|
| 32 |
:: |
| 33 |
|
| 34 |
$ pip install braceexpand |
| 35 |
|
| 36 |
Examples |
| 37 |
-------- |
| 38 |
|
| 39 |
The ``braceexpand`` function returns an iterator over the expansions |
| 40 |
generated from a pattern. |
| 41 |
|
| 42 |
.. code:: python |
| 43 |
|
| 44 |
>>> from braceexpand import braceexpand |
| 45 |
|
| 46 |
# Integer range |
| 47 |
>>> list(braceexpand('item{1..3}')) |
| 48 |
['item1', 'item2', 'item3'] |
| 49 |
|
| 50 |
# Character range |
| 51 |
>>> list(braceexpand('{a..c}')) |
| 52 |
['a', 'b', 'c'] |
| 53 |
|
| 54 |
# Sequence |
| 55 |
>>> list(braceexpand('index.html{,.backup}')) |
| 56 |
['index.html', 'index.html.backup'] |
| 57 |
|
| 58 |
# Nested patterns |
| 59 |
>>> list(braceexpand('python{2.{5..7},3.{2,3}}')) |
| 60 |
['python2.5', 'python2.6', 'python2.7', 'python3.2', 'python3.3'] |
| 61 |
|
| 62 |
# Prefixing an integer with zero causes all numbers to be padded to |
| 63 |
# the same width. |
| 64 |
>>> list(braceexpand('{07..10}')) |
| 65 |
['07', '08', '09', '10'] |
| 66 |
|
| 67 |
# An optional increment can be specified for ranges. |
| 68 |
>>> list(braceexpand('{a..g..2}')) |
| 69 |
['a', 'c', 'e', 'g'] |
| 70 |
|
| 71 |
# Ranges can go in both directions. |
| 72 |
>>> list(braceexpand('{4..1}')) |
| 73 |
['4', '3', '2', '1'] |
| 74 |
|
| 75 |
# Numbers can be negative |
| 76 |
>>> list(braceexpand('{2..-1}')) |
| 77 |
['2', '1', '0', '-1'] |
| 78 |
|
| 79 |
# Unbalanced braces raise an exception. |
| 80 |
>>> list(braceexpand('{1{2,3}')) |
| 81 |
Traceback (most recent call last): |
| 82 |
... |
| 83 |
UnbalancedBracesError: Unbalanced braces: '{1{2,3}' |
| 84 |
|
| 85 |
# By default, the backslash is the escape character. |
| 86 |
>>> list(braceexpand(r'{1\{2,3}')) |
| 87 |
['1{2', '3'] |
| 88 |
|
| 89 |
# Setting 'escape' to False disables backslash escaping. |
| 90 |
>>> list(braceexpand(r'\{1,2}', escape=False)) |
| 91 |
['\\1', '\\2'] |
| 92 |
|
| 93 |
License |
| 94 |
------- |
| 95 |
|
| 96 |
braceexpand is licensed under the MIT License. See the included file |
| 97 |
``LICENSE`` for details. |
| 98 |
|
| 99 |
.. |build-status-img| image:: https://travis-ci.org/trendels/braceexpand.svg |
| 100 |
:target: https://travis-ci.org/trendels/braceexpand |
| 101 |
.. |PyPI| image:: https://img.shields.io/pypi/v/braceexpand |
| 102 |
:target: https://pypi.python.org/pypi/braceexpand |
| 103 |
|
| 104 |
Platform: UNKNOWN |
| 105 |
Classifier: License :: OSI Approved :: MIT License |
| 106 |
Classifier: Programming Language :: Python |
| 107 |
Classifier: Programming Language :: Python :: 2 |
| 108 |
Classifier: Programming Language :: Python :: 3 |