Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/eiri/echolalia
Generate random data
https://github.com/eiri/echolalia
cli prototype python random-generation
Last synced: 28 days ago
JSON representation
Generate random data
- Host: GitHub
- URL: https://github.com/eiri/echolalia
- Owner: eiri
- License: mit
- Created: 2015-07-26T18:45:08.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2024-02-05T02:10:30.000Z (9 months ago)
- Last Synced: 2024-02-05T03:27:36.712Z (9 months ago)
- Topics: cli, prototype, python, random-generation
- Language: Python
- Homepage:
- Size: 59.6 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Echolalia
![project: prototype](https://img.shields.io/badge/project-prototype-orange.svg "Project: Prototype")
[![Build Status](https://github.com/eiri/echolalia/workflows/CI/badge.svg)](https://github.com/eiri/echolalia/actions)Generate random data to test your application
## Installation
Clone repo with `git clone https://github.com/eiri/echolalia-prototype.git`, create and active virtual environment with `python -m venv venv` and `. venv/bin/activate`, then install requirements with `pip install -r requirements.txt`.
## Usage
```bash
$ ./echolalia.py -c 2 -t templates/people.json -w stdout
[{"name": {"lastName": "Shannon", "firstName": "Rhonda"}, "tags": ["nihil", "fngheqnl", "impedit", "consequatur"], "age": 30, "state": "Hawaii, AR", "sex": "F", "phone": "03744269231", "single": true, "street": "4081 Sharon Ranch Apt. 197", "postcode": "ZIP: 02709-0053", "times": {"createdAt": "2017-02-13 13:14:08", "updatedAt": "2017-09-23 15:37:29"}, "email": "[email protected]"}, {"name": {"lastName": "Hanson", "firstName": "Robert"}, "tags": ["quasi", "##tuesday###", "deserunt", "laborum"], "age": 104, "state": "Nevada, FL", "sex": "F", "phone": "(698)292-8761x6944", "single": false, "street": "3898 Alexandria Parkways", "postcode": "ZIP: 24439", "times": {"createdAt": "2017-05-03 03:16:21", "updatedAt": "2017-09-23 15:37:02"}, "email": "[email protected]"}]
``````bash
$ ./echolalia.py -c 2 -i name -i email=free_email -f csv
Bruce Day,[email protected]
Janice Turner,[email protected]```
## Templates
JSON document of expected structure where keys will be used as keys for generated document and values should be methods of [faker](https://github.com/joke2k/faker) library. If method suppose to get arguments, the value block should be defined as json object with "attr" for name of method and "args" for list of provided arguments.
While template must be an object, the keys can take list of methods to generate arrays. For complex values mustash style of template can be used (e.g. `"{state}, {state_abbr}"`). Additional element "postprocess" can be used to run specified command over generated value.
Take a look at `templates/people.json` file for example.
## Formatters
### Raw
Pass through, returns generated data as python object.### JSON
Marshalls data to JSON.### CSV
Marshalls data to CSV format. If command line argument `--with_headers` provided adds as a first line a list of keys. Generated object more than 1 level of depth smashed into string### YAML
Marshalls data in YAML. Collections always serialized in block style.## Writers
### StdOut
This is a basic plugin that just outputs generated data on the standard output.### File
Output to a specified with `-o` or `--output` file.## Licence
[MIT](https://github.com/eiri/echolalia/blob/master/LICENSE)