Arbitrary data generation library
Data Generator provides a grammar parser that can be used to generate strings from a source file.
python -m data_generator source.txtRandomizers can be created by providing a name and content:
STR_ONE
This is a string
STR_TWO
This is another string
Output of the source file is designated with the __OUTPUT__ randomizer:
__OUTPUT__
This string will print when data_generator is executed.
Strings are either short (single lines with whitespace stripped), or long (interpreted literally, including whitespace and newlines). Long strings begin on a new line and are denoted with a pipe at the beginning of each line.
SHORT_STRING
This is a short string. Extra spaces at the start will be removed.
LONG_STRING
|This is a long string.
| Extra spaces at the beginning will be included.
| Only the pipe delimiters will be removed.
Lists are sets of strings that randomly return one item at a time.
LIST_RANDOMIZER
- First item
- Second item
-
|Third item
|containing multiple lines
- Fourth item
Rotate lists are sets of strings that return each item, repeating in sequence.
LIST_RANDOMIZER
+ First item
+ Second item
+ Third item
Callers function as placeholders for randomizers. Any time a caller is included in a string, the randomizer is executed and the placeholder is changed to the output of the randomizer.
COUNT
- ten
- twenty
- thirty
__OUTPUT__
|I have {COUNT} dollars.
|You have {COUNT} dollars.
Pointers are very similar to callers, except that they do not generate additional content. Instead, they return the same value previously generated by the referenced randomizer.
COUNT
- ten
- twenty
- thirty
__OUTPUT__
|I have {COUNT} dollars.
|Again, I have {<COUNT} dollars.
Repeaters allow content to be generated multiple times.
__OUTPUT__
5*This string will repeat five times.