Credentials Class Idea
This commit is contained in:
parent
992c923be2
commit
9f449a916c
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
tts/
|
tts/
|
||||||
__pycache__/
|
__pycache__/
|
||||||
|
credentials/
|
||||||
|
|||||||
84
credentials.py
Normal file
84
credentials.py
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
|
class Credentials_Module():
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__()
|
||||||
|
self.Twitch_Credentials_List:list
|
||||||
|
self.Discord_Credentials_List:list
|
||||||
|
self.DB_Credentials_List:list
|
||||||
|
|
||||||
|
credentialLoadingFunctions = { # this is a mapping of the Credential enum to function pointers
|
||||||
|
Credential.Twitch_Credential: load_Twitch_Credential,
|
||||||
|
Credential.Discord_Credential: load_Discord_Credential,
|
||||||
|
Credential.DB_Credential: load_DB_Credential
|
||||||
|
}
|
||||||
|
|
||||||
|
def load_credentials(self):
|
||||||
|
credentialPath = self.get_credentials_dir()
|
||||||
|
fileList:list = []
|
||||||
|
for file in fileList:
|
||||||
|
fileName = ""
|
||||||
|
if fileName.lower().find("twitch") != -1:
|
||||||
|
credential_loading_function = self.credentialLoadingFunctions.get(Credential.Twitch_Credential)
|
||||||
|
output = credential_loading_function(fileName)
|
||||||
|
if fileName.lower().find("discord") != -1:
|
||||||
|
credential_loading_function = self.credentialLoadingFunctions.get(Credential.Discord_Credential)
|
||||||
|
output = credential_loading_function(fileName)
|
||||||
|
if fileName.lower().find("db") != -1:
|
||||||
|
credential_loading_function = self.credentialLoadingFunctions.get(Credential.DB_Credential)
|
||||||
|
output = credential_loading_function(fileName)
|
||||||
|
|
||||||
|
#Based on similar function in tts.py
|
||||||
|
def get_credentials_dir(self):
|
||||||
|
dir = os.path.join(os.getcwd(), "credentials") # this is platform-agnostic
|
||||||
|
if not os.path.exists(dir):
|
||||||
|
os.mkdir(dir)
|
||||||
|
return dir
|
||||||
|
|
||||||
|
def load_Twitch_Credential(self, fileName:str):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def load_Discord_Credential(self, fileName:str):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def load_DB_Credential(self, fileName:str):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class Credential(Enum):
|
||||||
|
Twitch_Credential = 1
|
||||||
|
Discord_Credential = 2
|
||||||
|
DB_Credential = 3
|
||||||
|
|
||||||
|
class Twitch_Credential():
|
||||||
|
#Username = Twitch Username
|
||||||
|
#Helix ID = https://dev.twitch.tv/console/apps
|
||||||
|
#Oauth = https://twitchapps.com/tmi/
|
||||||
|
#V5 Client ID = https://twitchtokengenerator.com/
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__()
|
||||||
|
username = ""
|
||||||
|
helix = ""
|
||||||
|
oauth = "oauth:"
|
||||||
|
v5_Client = ""
|
||||||
|
|
||||||
|
class Discord_Credential():
|
||||||
|
#Discord Credentials explanations here.
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__()
|
||||||
|
username = ""
|
||||||
|
|
||||||
|
class DB_Credential():
|
||||||
|
#engine = "mysql+mysqlconnector://root:password@localhost:3306/DatabaseName"
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__()
|
||||||
|
self.username = ""
|
||||||
|
self.password = ""
|
||||||
|
self.ipAddress = ""
|
||||||
|
self.port = ""
|
||||||
|
self.databaseName = ""
|
||||||
|
self.engine_url = ""
|
||||||
|
|
||||||
|
def create_engine_url(self):
|
||||||
|
new_engine_url = "mysql+mysqlconnector://" + self.username + ":" + self.password + "@" + self.ipAddress + ":" + self.port + "/" + self.databaseName
|
||||||
|
self.engine_url = new_engine_url
|
||||||
Loading…
Reference in New Issue
Block a user