Just another Data Offline Generator
Project description
Just another Data Offline Generator (JDOG) 🐶
🗎 Full documentation.
JDOG is a Python library which helps generate a sample data for your projects.
JDOG can also be run as CLI tool.
For generating a sample data, the data scheme is provided.
Scheme
The scheme is provided in JSON format with special placeholders.
In the output, the placeholders are replaced with some generated data.
Any valid JSON is valid scheme.
How to use it?
Install it
python -m pip install jdog
Prepare a scheme
{
"{{range(people,4)}}": {
"name": "{{name}}",
"age": "{{age}}",
"address": {
"city": "{{city}}"
},
"car": "{{option(mustang,{{empty}})}}"
}
}
Use it
from jdog import Jdog
def main():
jdog = Jdog()
scheme = ... # your loaded scheme
# parse scheme
jdog.parse_scheme(scheme)
# generate instance
result = jdog.generate()
print(result) # result is JSON
And the example result:
{
"people": [
{
"name": "Brandi Young",
"age": 39,
"address": {
"city": "Jamietown"
},
"car": "mustang"
},
{
"name": "Michelle Best",
"age": 70,
"address": {
"city": "Port Dustin"
},
"car": ""
},
{
"name": "Donald Hernandez",
"age": 79,
"address": {
"city": "East Julieshire"
},
"car": "mustang"
},
{
"name": "Kaitlyn Cook",
"age": 3,
"address": {
"city": "Rachelton"
},
"car": "mustang"
}
]
}
CLI
Package can be used as cli tool.
Usage: jdog [OPTIONS] SCHEME
Accepts SCHEME and generates new data to stdin or to specified OUTPUT
Options:
-p, --pretty Output as pretty JSON.
-s, --strict Raise error when no matching placeholder is found.
-l, --lang TEXT Language to use.
--lang-help Displays available language codes and exit.
-o, --output FILENAME Output file where result is written.
--help Show this message and exit.
By default, CLI tool does not save output to file, just print results to standard output.
👍 JDOG is using awesome package Faker which is used to generate random data.
CONTRIBUTING
LICENSE
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file jdog-1.0.0.tar.gz
.
File metadata
- Download URL: jdog-1.0.0.tar.gz
- Upload date:
- Size: 10.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e2a0c6c5b00a934831230ede731f1b0a9968c82065e8296641637b955a4b4f4c |
|
MD5 | 11310cd670de34cc39b40a4ce9b25d86 |
|
BLAKE2b-256 | 1eddeabe378c6994ad1806f8b28f180e2a76253ccb5c56988f3766408ec53cbc |