janny/utils.py (view raw)
1 2 3 4 5 6 7 8 9 10 11 12 13 |
import logging
import json
from types import SimpleNamespace
from janny.config import API_HOST
from janny.auth import SESSION
def get(path):
"""Convert a JSON response into a Python object"""
s = SESSION
data = s.get(API_HOST + path).content
obj = json.loads(data, object_hook=lambda d: SimpleNamespace(**d))
return obj
|