Utils
Data generation utilities.
ensure_id_generator(cls)
Ensure class has ID generator.
Source code in src/snailz/utils.py
12 13 14 15 16 | |
file_or_std(parent, filename, mode)
Open file and return handle or return stdin/stdout.
Source code in src/snailz/utils.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | |
id_gen(stem, digits)
Generate unique IDs of the form 'stemDDDD'.
Source code in src/snailz/utils.py
37 38 39 40 41 42 43 44 45 | |
json_dump(obj, indent=2)
Dump as JSON with custom serializer.
Source code in src/snailz/utils.py
48 49 50 51 | |
random_date(params)
Select random date in range (inclusive).
Source code in src/snailz/utils.py
54 55 56 57 58 | |
random_mass(params)
Generate random sample mass.
Source code in src/snailz/utils.py
61 62 63 64 65 66 67 | |
_serialize_json(obj)
Custom JSON serializer.
Source code in src/snailz/utils.py
70 71 72 73 74 75 76 77 | |