wiki-postbot/wiki_postbot/creds.py
2022-10-15 20:15:33 -07:00

55 lines
No EOL
1.2 KiB
Python

"""
No, not the actual creds. and dont go lookin for em in the git history cuz they aint in there neither
"""
import json
from dataclasses import dataclass
from pathlib import Path
import typing
@dataclass
class Creds:
api_key: str
api_secret: str
bearer_token: str
access_token: typing.Optional[str]
access_secret: typing.Optional[str]
@classmethod
def from_json(cls, path:Path) -> 'Creds':
with open(path, 'r') as jfile:
creds = json.load(jfile)
return Creds(**creds)
@dataclass
class Zenodo_Creds:
access_token:str
@classmethod
def from_json(cls, path:Path) -> 'Zenodo_Creds':
with open(path, 'r') as jfile:
creds = json.load(jfile)
return Zenodo_Creds(**creds)
@dataclass
class Discord_Creds:
token:str
@classmethod
def from_json(cls, path:Path) -> 'Discord_Creds':
with open(path, 'r') as jfile:
creds = json.load(jfile)
return Discord_Creds(**creds)
@dataclass
class Mediawiki_Creds:
user:str
password:str
@classmethod
def from_json(cls, path:Path) -> 'Mediawiki_Creds':
with open(path, 'r') as jfile:
creds = json.load(jfile)
return Mediawiki_Creds(**creds)