File size: 439 Bytes
703e6fc
 
458f0bb
b4cd98c
 
458f0bb
703e6fc
b4cd98c
703e6fc
9a20d2b
b4cd98c
ac0d8be
 
b4cd98c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import json


def extract(info_str):
    """Extract user, source, username, and all info"""
    info = {}  # a copy of hf_token in json format
    try:
        info = dict(json.loads(info_str))
    except json.decoder.JSONDecodeError:
        return "__fake__", None, None, None
    user = info.get("user", "__fake__")
    source = info.get("source", None)
    username = info.get("username", None)
    return user, source, username, info