braceexpand


Namebraceexpand JSON
Version 0.1.7 PyPI version JSON
download
home_pagehttps://github.com/trendels/braceexpand
SummaryBash-style brace expansion for Python
upload_time2021-05-07 13:49:07
maintainer
docs_urlNone
authorStanis Trendelenburg
requires_python
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI
coveralls test coverage No coveralls.
            Bash-style brace expansion for Python
=====================================

|build-status-img| |PyPI|

Implements Brace Expansion as described in
`bash(1) <http://man7.org/linux/man-pages/man1/bash.1.html#EXPANSION>`__,
with the following limitations:

-  A pattern containing unbalanced braces will raise an
   ``UnbalancedBracesError`` exception. In bash, unbalanced braces will
   either be partly expanded or ignored.

-  A mixed-case character range like ``'{Z..a}'`` or ``'{a..Z}'`` will
   not include the characters :literal:`[]^_\`` between ``Z`` and ``a``.

``braceexpand`` is tested with Python 2.7, and 3.6+

Installation
------------

Install the ``braceexpand`` package from pypi:

::

   $ pip install braceexpand

Examples
--------

The ``braceexpand`` function returns an iterator over the expansions
generated from a pattern.

.. code:: python

   >>> from braceexpand import braceexpand

   # Integer range
   >>> list(braceexpand('item{1..3}'))
   ['item1', 'item2', 'item3']

   # Character range
   >>> list(braceexpand('{a..c}'))
   ['a', 'b', 'c']

   # Sequence
   >>> list(braceexpand('index.html{,.backup}'))
   ['index.html', 'index.html.backup']

   # Nested patterns
   >>> list(braceexpand('python{2.{5..7},3.{2,3}}'))
   ['python2.5', 'python2.6', 'python2.7', 'python3.2', 'python3.3']

   # Prefixing an integer with zero causes all numbers to be padded to
   # the same width.
   >>> list(braceexpand('{07..10}'))
   ['07', '08', '09', '10']

   # An optional increment can be specified for ranges.
   >>> list(braceexpand('{a..g..2}'))
   ['a', 'c', 'e', 'g']

   # Ranges can go in both directions.
   >>> list(braceexpand('{4..1}'))
   ['4', '3', '2', '1']

   # Numbers can be negative
   >>> list(braceexpand('{2..-1}'))
   ['2', '1', '0', '-1']

   # Unbalanced braces raise an exception.
   >>> list(braceexpand('{1{2,3}'))
   Traceback (most recent call last):
       ...
   UnbalancedBracesError: Unbalanced braces: '{1{2,3}'

   # By default, the backslash is the escape character.
   >>> list(braceexpand(r'{1\{2,3}'))
   ['1{2', '3']

   # Setting 'escape' to False disables backslash escaping.
   >>> list(braceexpand(r'\{1,2}', escape=False))
   ['\\1', '\\2']

License
-------

braceexpand is licensed under the MIT License. See the included file
``LICENSE`` for details.

.. |build-status-img| image:: https://travis-ci.org/trendels/braceexpand.svg
   :target: https://travis-ci.org/trendels/braceexpand
.. |PyPI| image:: https://img.shields.io/pypi/v/braceexpand
   :target: https://pypi.python.org/pypi/braceexpand



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/trendels/braceexpand",
    "name": "braceexpand",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "",
    "author": "Stanis Trendelenburg",
    "author_email": "stanis.trendelenburg@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/54/93/badd4f5ccf25209f3fef2573073da9fe4a45a3da99fca2f800f942130c0f/braceexpand-0.1.7.tar.gz",
    "platform": "",
    "description": "Bash-style brace expansion for Python\n=====================================\n\n|build-status-img| |PyPI|\n\nImplements Brace Expansion as described in\n`bash(1) <http://man7.org/linux/man-pages/man1/bash.1.html#EXPANSION>`__,\nwith the following limitations:\n\n-  A pattern containing unbalanced braces will raise an\n   ``UnbalancedBracesError`` exception. In bash, unbalanced braces will\n   either be partly expanded or ignored.\n\n-  A mixed-case character range like ``'{Z..a}'`` or ``'{a..Z}'`` will\n   not include the characters :literal:`[]^_\\`` between ``Z`` and ``a``.\n\n``braceexpand`` is tested with Python 2.7, and 3.6+\n\nInstallation\n------------\n\nInstall the ``braceexpand`` package from pypi:\n\n::\n\n   $ pip install braceexpand\n\nExamples\n--------\n\nThe ``braceexpand`` function returns an iterator over the expansions\ngenerated from a pattern.\n\n.. code:: python\n\n   >>> from braceexpand import braceexpand\n\n   # Integer range\n   >>> list(braceexpand('item{1..3}'))\n   ['item1', 'item2', 'item3']\n\n   # Character range\n   >>> list(braceexpand('{a..c}'))\n   ['a', 'b', 'c']\n\n   # Sequence\n   >>> list(braceexpand('index.html{,.backup}'))\n   ['index.html', 'index.html.backup']\n\n   # Nested patterns\n   >>> list(braceexpand('python{2.{5..7},3.{2,3}}'))\n   ['python2.5', 'python2.6', 'python2.7', 'python3.2', 'python3.3']\n\n   # Prefixing an integer with zero causes all numbers to be padded to\n   # the same width.\n   >>> list(braceexpand('{07..10}'))\n   ['07', '08', '09', '10']\n\n   # An optional increment can be specified for ranges.\n   >>> list(braceexpand('{a..g..2}'))\n   ['a', 'c', 'e', 'g']\n\n   # Ranges can go in both directions.\n   >>> list(braceexpand('{4..1}'))\n   ['4', '3', '2', '1']\n\n   # Numbers can be negative\n   >>> list(braceexpand('{2..-1}'))\n   ['2', '1', '0', '-1']\n\n   # Unbalanced braces raise an exception.\n   >>> list(braceexpand('{1{2,3}'))\n   Traceback (most recent call last):\n       ...\n   UnbalancedBracesError: Unbalanced braces: '{1{2,3}'\n\n   # By default, the backslash is the escape character.\n   >>> list(braceexpand(r'{1\\{2,3}'))\n   ['1{2', '3']\n\n   # Setting 'escape' to False disables backslash escaping.\n   >>> list(braceexpand(r'\\{1,2}', escape=False))\n   ['\\\\1', '\\\\2']\n\nLicense\n-------\n\nbraceexpand is licensed under the MIT License. See the included file\n``LICENSE`` for details.\n\n.. |build-status-img| image:: https://travis-ci.org/trendels/braceexpand.svg\n   :target: https://travis-ci.org/trendels/braceexpand\n.. |PyPI| image:: https://img.shields.io/pypi/v/braceexpand\n   :target: https://pypi.python.org/pypi/braceexpand\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Bash-style brace expansion for Python",
    "version": "0.1.7",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "89037c104cb409cad1be862e02f38967",
                "sha256": "91332d53de7828103dcae5773fb43bc34950b0c8160e35e0f44c4427a3b85014"
            },
            "downloads": -1,
            "filename": "braceexpand-0.1.7-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "89037c104cb409cad1be862e02f38967",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 5923,
            "upload_time": "2021-05-07T13:49:05",
            "upload_time_iso_8601": "2021-05-07T13:49:05.146788Z",
            "url": "https://files.pythonhosted.org/packages/fa/93/e8c04e80e82391a6e51f218ca49720f64236bc824e92152a2633b74cf7ab/braceexpand-0.1.7-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "59f9561f770011d1947b813024e3dcac",
                "sha256": "e6e539bd20eaea53547472ff94f4fb5c3d3bf9d0a89388c4b56663aba765f705"
            },
            "downloads": -1,
            "filename": "braceexpand-0.1.7.tar.gz",
            "has_sig": false,
            "md5_digest": "59f9561f770011d1947b813024e3dcac",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 7777,
            "upload_time": "2021-05-07T13:49:07",
            "upload_time_iso_8601": "2021-05-07T13:49:07.323370Z",
            "url": "https://files.pythonhosted.org/packages/54/93/badd4f5ccf25209f3fef2573073da9fe4a45a3da99fca2f800f942130c0f/braceexpand-0.1.7.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2021-05-07 13:49:07",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "trendels",
    "github_project": "braceexpand",
    "travis_ci": true,
    "coveralls": false,
    "github_actions": false,
    "lcname": "braceexpand"
}
        
Elapsed time: 0.02313s