b_demo_hf / extract.py
steveagi's picture
add redirect to different proxy
d1c021a
raw
history blame
638 Bytes
import json
def extract(hf_token):
"""
Extract token, user, redirect, and info from input hf_token.
If hf_token is simple, it is the token itself.
"""
info = {} # a copy of hf_token in json format
try:
info = json.loads(hf_token)
except json.decoder.JSONDecodeError:
return hf_token, None, None, None
try:
token = info['token']
except KeyError:
token = None
try:
user = info['user']
except KeyError:
user = None
try:
redirect = info['redirect']
except KeyError:
redirect = None
return token, user, redirect, info