wiki-postbot/wiki_postbot/creds.py

68 lines
1.5 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)
@dataclass
class Slack_Creds:
app_token:str
bot_token:str
@classmethod
@classmethod
def from_json(cls, path:Path) -> 'Slack_Creds':
"""jesus christ this package is so sloppy"""
with open(path, 'r') as jfile:
creds = json.load(jfile)
return Slack_Creds(**creds)