File: util.py

package info (click to toggle)
python-authlib 1.6.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,016 kB
  • sloc: python: 26,998; makefile: 53; sh: 14
file content (22 lines) | stat: -rw-r--r-- 471 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import json
import os

from authlib.common.encoding import to_unicode
from authlib.common.urls import url_decode

ROOT = os.path.abspath(os.path.dirname(__file__))


def get_file_path(name):
    return os.path.join(ROOT, "files", name)


def read_file_path(name):
    with open(get_file_path(name)) as f:
        if name.endswith(".json"):
            return json.load(f)
        return f.read()


def decode_response(data):
    return dict(url_decode(to_unicode(data)))