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