forked from OpenBB-finance/OpenBB
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcredentials_model.py
More file actions
26 lines (20 loc) · 818 Bytes
/
credentials_model.py
File metadata and controls
26 lines (20 loc) · 818 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import json
from dataclasses import make_dataclass
from pydantic.dataclasses import dataclass as pydanticdataclass
from openbb_terminal.core.config.paths import MISCELLANEOUS_DIRECTORY
from openbb_terminal.core.models.base_model import BaseModel
with open(MISCELLANEOUS_DIRECTORY / "models" / "hub_credentials.json") as f:
HUB_CREDENTIALS = json.load(f)
with open(MISCELLANEOUS_DIRECTORY / "models" / "local_credentials.json") as f:
LOCAL_CREDENTIALS = json.load(f)
dc = make_dataclass(
cls_name="CredentialsModel",
fields=[
(k, str, "REPLACE_ME") for k in list(HUB_CREDENTIALS) + list(LOCAL_CREDENTIALS)
],
bases=(BaseModel,),
)
dc.__repr__ = dc.__base__.__repr__ # type: ignore
CredentialsModel = pydanticdataclass(
dc, config=dict(validate_assignment=True, frozen=True)
)