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