Skip to main content

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.

__init__

 | __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.

generate_all

 | 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.

generate

 | 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)

Metadata

Release files for stringbrewer 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for stringbrewer 0.0.1
File Size Uploaded Provenance Actions
stringbrewer-0.0.1.tar.gz 4.0 kB Without provenance Details for stringbrewer-0.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for stringbrewer 0.0.1
File Interpreter ABI Platform Actions
stringbrewer-0.0.1-py3-none-any.whl Python 3 none any Details for stringbrewer-0.0.1-py3-none-any.whl

Total release size: 8.9 kB

Release files / stringbrewer-0.0.1.tar.gz

Download URL stringbrewer-0.0.1.tar.gz
Size 4.0 kB
Tags Source
SHA-256 checksum
How to use checksums
c2d113822f9393500b273cc833a21ce739036c02c62f47042e0f17ef9b9ea649
BLAKE2b-256 checksum
How to use checksums
a92e341077c34244cb99a2c245e7f158013ba101427330e14fa4d3d4b6f72530
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/18.5 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/2.7.16

Release files / stringbrewer-0.0.1-py3-none-any.whl

Download URL stringbrewer-0.0.1-py3-none-any.whl
Size 4.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c04c37a9874a9645b6c311897fcb1f7c7a0c787d207e4777ca966ebd3685d7c3
BLAKE2b-256 checksum
How to use checksums
04e86104ffdc8d892e2b9a5e584346d38fcb8d858c8fec0f586e64d1899bcd61
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/18.5 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/2.7.16

Security for stringbrewer 0.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page