Skip to content
This repository has been archived by the owner on Jul 18, 2022. It is now read-only.

Commit

Permalink
Change commit format from TOML to YAML (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
PerchunPak committed Feb 19, 2022
1 parent ba88b32 commit 8595933
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 28 deletions.
4 changes: 2 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ docs/
.builds
tests
.editorconfig
config.toml.example
config.yml.example
Makefile
setup.cfg
.readthedocs.yml
Expand Down Expand Up @@ -306,5 +306,5 @@ $RECYCLE.BIN/
# End of https://www.toptal.com/developers/gitignore/api/linux,python,windows,pycharm+all,visualstudiocode

docs/modules/autodonate*.rst
config.toml
config.yml
logs/
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -294,5 +294,5 @@ $RECYCLE.BIN/
# End of https://www.toptal.com/developers/gitignore/api/linux,python,windows,pycharm+all,visualstudiocode

docs/modules/autodonate*.rst
config.toml
config.yml
logs/
18 changes: 9 additions & 9 deletions autodonate/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from os import environ
from shutil import copy as copy_file
from pathlib import Path
from toml import load as toml_decode
from yaml import safe_load as yaml_decode
from json import loads as json_decode
from typing import Any
from autodonate.lib.utils.logger import get_logger
Expand Down Expand Up @@ -144,10 +144,10 @@ def __init__(self) -> None:
# if there "DONATE_CONFIG" use it
if environ.get("DONATE_CONFIG") and Path(environ["DONATE_CONFIG"]).is_file():
self.CONFIG_PATH: Path = Path(environ["DONATE_CONFIG"])
elif Path("/config/config.toml").is_file():
self.CONFIG_PATH: Path = Path("/config/config.toml") # type: ignore[no-redef]
elif Path("/config/config.yml").is_file():
self.CONFIG_PATH: Path = Path("/config/config.yml") # type: ignore[no-redef]
else:
self.CONFIG_PATH: Path = BASE_DIR / "config.toml" # type: ignore[no-redef]
self.CONFIG_PATH: Path = BASE_DIR / "config.yml" # type: ignore[no-redef]

# loading the config
if self.CONFIG_PATH.exists():
Expand All @@ -158,12 +158,12 @@ def __init__(self) -> None:
+ "the DONATE_CONFIG environment variable, or add settings "
+ "directly to environment variables. You can get the actual "
+ "config from the link: "
+ "https://raw.githubusercontent.com/fire-squad/autodonate/master/config.toml",
+ "https://raw.githubusercontent.com/fire-squad/autodonate/master/config.yml.example",
)
if (BASE_DIR / "config.toml.example").is_file():
copy_file(str(BASE_DIR / "config.toml.example"), str(self.CONFIG_PATH))
if (BASE_DIR / "config.yml.example").is_file():
copy_file(str(BASE_DIR / "config.yml.example"), str(self.CONFIG_PATH))
log.warning(
'config.toml.example found, copied to "%s" and used '
'config.yml.example found, copied to "%s" and used '
% str(self.CONFIG_PATH)
+ "as config"
)
Expand Down Expand Up @@ -200,7 +200,7 @@ def get(self, config_item: str, default: Any = ConfigNone) -> Any: # type: igno
def _load(self) -> None:
"""Load config file."""
with open(str(self.CONFIG_PATH), "r") as opened_file:
self.CONFIG = toml_decode(opened_file)
self.CONFIG = yaml_decode(opened_file)

def _check(self) -> None:
"""Checking all necessary variables before starting."""
Expand Down
11 changes: 0 additions & 11 deletions config.toml.example

This file was deleted.

13 changes: 13 additions & 0 deletions config.yml.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
SECRET_KEY: "Sup3rsecr33tranDomstr1ng"
DEBUG: true
ALLOWED_HOSTS: ["host1.ru", "host2.com", "*.something.info"]

# RCON settings
RCON_HOST: "localhost"
RCON_PASSWORD: "Sup3rsecr33tranDomstr1ng"
RCON_PORT: 25575 # optional

# Change this to your db config or path
DATABASE:
ENGINE: "django.db.backends.sqlite3"
NAME: "db.sqlite3"
3 changes: 2 additions & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ sphinxcontrib-apidoc>=0.3.0
furo>=2022.1.2
m2r2>=0.3.0,<0.4.0
tomlkit>=0.10.0,<0.11.0
toml>=0.10.2,<0.11.0

# Dependencies of our project:
Django>=4.0.2,<4.1.0
requests>=2.27.1
toml>=0.10.2,<0.11.0
PyYAML>=6.0,<7.0
mcrcon-ipv6>=0.1.2
6 changes: 3 additions & 3 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ python = "^3.10"
poetry = "^1"
Django = "^4.0.2"
requests = "^2.27.1"
toml = "^0.10.2"
PyYAML = "^6.0"
mcrcon-ipv6 = "^0.1.2"

[tool.poetry.dev-dependencies]
Expand All @@ -43,3 +43,4 @@ furo = "^2022.1.2"
doc8 = "^0.10"
m2r2 = "^0.3"
tomlkit = "^0.10"
toml = "^0.10.2"

0 comments on commit 8595933

Please sign in to comment.