core: more generic functions to jsonify data, rescuetime: fix influxdb filling
This commit is contained in:
parent
07f901e1e5
commit
4012f9b7c2
5 changed files with 65 additions and 32 deletions
|
@ -471,3 +471,13 @@ def asdict(thing) -> Json:
|
|||
# must be a NT otherwise?
|
||||
# todo add a proper check.. ()
|
||||
return thing._asdict()
|
||||
|
||||
|
||||
# todo not sure about naming
|
||||
def to_jsons(it) -> Iterable[Json]:
|
||||
from .error import error_to_json # prevent circular import
|
||||
for r in it:
|
||||
if isinstance(r, Exception):
|
||||
yield error_to_json(r)
|
||||
else:
|
||||
yield asdict(r)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue