stringbrewer


Namestringbrewer JSON
Version 0.0.1 PyPI version JSON
download
home_pagehttps://github.com/simoncozens/stringbrewer
SummaryGenerate random strings matching a pattern
upload_time2020-08-10 09:47:21
maintainer
docs_urlNone
authorSimon Cozens
requires_python
licenseMIT
keywords
VCS
bugtrack_url
requirements rstr sre_yield
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <a name="stringbrewer"></a>
# stringbrewer: Generate random strings matching a pattern.

Patterns are specified in the StringBrewer pattern language, and are made
up of two parts: a *recipe* and a set of *ingredients*. A recipe is
essentially a modified form of regular expression; whitespace is not
significant, and each ingredient name is replaced by its definition. An
*ingredient* is a space-separated list of items; each item is either a
character (specified either as a literal character or as a Unicode
codepoint in hexadecimal), a range of characters separated by hyphens,
or a union of items separated by commas. Ingredients may also contain
references to other ingredients.

This is best understood by example. The pattern below generates
Telugu morphemes::

    # Generate random Telugu-like morphemes
    (Base HalantGroup{0,2} TopPositionedVowel?){1,3}

    Base = క-న,ప-హ
    Halant = 0C4D
    HalantGroup = Halant Base
    TopPositionedVowel = 0C46-0C48,0C4A-0C4C

The first line is a comment; the second is the recipe, and the blank line
denotes the beginning of the ingredients list. Let's look at the ingredients.
A ``Base`` is any character either in the range ``0x0C15-0C28`` or ``0C2A-0C39``.
(We specified these as literals, just because we could). A ``Halant`` is the
character ``0x0C4D``. A ``HalantGroup`` is a halant followed by a base.

Now you understand the ingredients, the recipe is simple to understand if you
think in terms of regular expression syntax: a base followed by zero, one or
two halant groups, plus an optional top-positioned vowel, all repeated between
one and three times.

<a name="stringbrewer.StringBrewer.__init__"></a>
#### \_\_init\_\_

```python
 | __init__(from_string=None, from_file=None, recipe=None, ingredients=None)
```

Initializes a StringBrewer object

You must provide *either* a file name, a string, or a recipe
string and ingredients dictionary.

**Arguments**:

- `from_file` - A file name of a file containing a pattern.
- `from_string` - A pattern in a string.
- `recipe` - The recipe part of a pattern.
- `ingredients` - A dictionary of regular expressions.

<a name="stringbrewer.StringBrewer.generate_all"></a>
#### generate\_all

```python
 | generate_all()
```

Generates a list of all combinations.

If there are more than 100,000 combinations, an exception
is raised to avoid running out of memory.

<a name="stringbrewer.StringBrewer.generate"></a>
#### generate

```python
 | generate(min_length=0, max_length=None)
```

Generates a single random combination.

**Arguments**:

- `min_length` - Minimum length (zero if not specified)
- `max_length` - Maximum length (no maximum if not specified)




            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/simoncozens/stringbrewer",
    "name": "stringbrewer",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "",
    "author": "Simon Cozens",
    "author_email": "simon@simon-cozens.org",
    "download_url": "https://files.pythonhosted.org/packages/a9/2e/341077c34244cb99a2c245e7f158013ba101427330e14fa4d3d4b6f72530/stringbrewer-0.0.1.tar.gz",
    "platform": "",
    "description": "<a name=\"stringbrewer\"></a>\n# stringbrewer: Generate random strings matching a pattern.\n\nPatterns are specified in the StringBrewer pattern language, and are made\nup of two parts: a *recipe* and a set of *ingredients*. A recipe is\nessentially a modified form of regular expression; whitespace is not\nsignificant, and each ingredient name is replaced by its definition. An\n*ingredient* is a space-separated list of items; each item is either a\ncharacter (specified either as a literal character or as a Unicode\ncodepoint in hexadecimal), a range of characters separated by hyphens,\nor a union of items separated by commas. Ingredients may also contain\nreferences to other ingredients.\n\nThis is best understood by example. The pattern below generates\nTelugu morphemes::\n\n    # Generate random Telugu-like morphemes\n    (Base HalantGroup{0,2} TopPositionedVowel?){1,3}\n\n    Base = \u0c15-\u0c28,\u0c2a-\u0c39\n    Halant = 0C4D\n    HalantGroup = Halant Base\n    TopPositionedVowel = 0C46-0C48,0C4A-0C4C\n\nThe first line is a comment; the second is the recipe, and the blank line\ndenotes the beginning of the ingredients list. Let's look at the ingredients.\nA ``Base`` is any character either in the range ``0x0C15-0C28`` or ``0C2A-0C39``.\n(We specified these as literals, just because we could). A ``Halant`` is the\ncharacter ``0x0C4D``. A ``HalantGroup`` is a halant followed by a base.\n\nNow you understand the ingredients, the recipe is simple to understand if you\nthink in terms of regular expression syntax: a base followed by zero, one or\ntwo halant groups, plus an optional top-positioned vowel, all repeated between\none and three times.\n\n<a name=\"stringbrewer.StringBrewer.__init__\"></a>\n#### \\_\\_init\\_\\_\n\n```python\n | __init__(from_string=None, from_file=None, recipe=None, ingredients=None)\n```\n\nInitializes a StringBrewer object\n\nYou must provide *either* a file name, a string, or a recipe\nstring and ingredients dictionary.\n\n**Arguments**:\n\n- `from_file` - A file name of a file containing a pattern.\n- `from_string` - A pattern in a string.\n- `recipe` - The recipe part of a pattern.\n- `ingredients` - A dictionary of regular expressions.\n\n<a name=\"stringbrewer.StringBrewer.generate_all\"></a>\n#### generate\\_all\n\n```python\n | generate_all()\n```\n\nGenerates a list of all combinations.\n\nIf there are more than 100,000 combinations, an exception\nis raised to avoid running out of memory.\n\n<a name=\"stringbrewer.StringBrewer.generate\"></a>\n#### generate\n\n```python\n | generate(min_length=0, max_length=None)\n```\n\nGenerates a single random combination.\n\n**Arguments**:\n\n- `min_length` - Minimum length (zero if not specified)\n- `max_length` - Maximum length (no maximum if not specified)\n\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Generate random strings matching a pattern",
    "version": "0.0.1",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "851c76b82322726353e33aecf33a3ebf",
                "sha256": "c04c37a9874a9645b6c311897fcb1f7c7a0c787d207e4777ca966ebd3685d7c3"
            },
            "downloads": -1,
            "filename": "stringbrewer-0.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "851c76b82322726353e33aecf33a3ebf",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 4870,
            "upload_time": "2020-08-10T09:47:18",
            "upload_time_iso_8601": "2020-08-10T09:47:18.755185Z",
            "url": "https://files.pythonhosted.org/packages/04/e8/6104ffdc8d892e2b9a5e584346d38fcb8d858c8fec0f586e64d1899bcd61/stringbrewer-0.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "aadd6d5e1cca165b9e65870089a9ab7d",
                "sha256": "c2d113822f9393500b273cc833a21ce739036c02c62f47042e0f17ef9b9ea649"
            },
            "downloads": -1,
            "filename": "stringbrewer-0.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "aadd6d5e1cca165b9e65870089a9ab7d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 3982,
            "upload_time": "2020-08-10T09:47:21",
            "upload_time_iso_8601": "2020-08-10T09:47:21.337673Z",
            "url": "https://files.pythonhosted.org/packages/a9/2e/341077c34244cb99a2c245e7f158013ba101427330e14fa4d3d4b6f72530/stringbrewer-0.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2020-08-10 09:47:21",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "simoncozens",
    "github_project": "stringbrewer",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "rstr",
            "specs": []
        },
        {
            "name": "sre_yield",
            "specs": []
        }
    ],
    "lcname": "stringbrewer"
}
        
Elapsed time: 0.02371s