Skip to content

Commit

Permalink
Revert "Fix pages" (#55)
Browse files Browse the repository at this point in the history
* Revert "Fix pages (#54)"

This reverts commit 83c4a67.

* Added dry-run default

* Full dry run
  • Loading branch information
Tech-TTGames authored Mar 17, 2023
1 parent 83c4a67 commit b271ad8
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions tickets_plus/database/statvars.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import pathlib
import string
from logging import handlers
from typing import TYPE_CHECKING, Any, Literal
from typing import Any, Literal

import discord
import sqlalchemy
Expand Down Expand Up @@ -76,13 +76,16 @@ def __init__(self) -> None:
We also store the token in self.token for easy access.
"""
self._file = pathlib.Path(PROG_DIR, "secret.json")
if not TYPE_CHECKING:
try:
with open(self._file, encoding="utf-8", mode="r") as secret_f:
self.secrets = json.load(secret_f)
self.token: str = self.secrets["token"]
except FileNotFoundError:
logging.warning("Running in dry-run mode.")
self._file = pathlib.Path(PROG_DIR, "example_secret.json")
with open(self._file, encoding="utf-8", mode="r") as secret_f:
self.secrets = json.load(secret_f)
self.token: str = self.secrets["token"]
else:
self.secrets = {}
self.token = ""

def __repr__(self) -> str:
return "[OBFUSCATED]"
Expand All @@ -103,11 +106,14 @@ class MiniConfig:

def __init__(self) -> None:
self._file = pathlib.Path(PROG_DIR, "config.json")
if not TYPE_CHECKING:
try:
with open(self._file, encoding="utf-8", mode="r") as config_f:
self._config: dict = json.load(config_f)
except FileNotFoundError:
logging.warning("Running in dry-run mode.")
self._file = pathlib.Path(PROG_DIR, "example_config.json")
with open(self._file, encoding="utf-8", mode="r") as config_f:
self._config: dict = json.load(config_f)
else:
self._config: dict = {}

def __dict__(self) -> dict:
return self._config
Expand Down

0 comments on commit b271ad8

Please sign in to comment.