1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-26 21:14:19 +00:00

🐞 Fix scroll access and bump to 6.0.0a4

This commit is contained in:
Steffo 2020-10-28 19:04:45 +01:00
parent 191ed0605d
commit bf949fed55
2 changed files with 5 additions and 5 deletions

View file

@ -1,6 +1,6 @@
[tool.poetry] [tool.poetry]
name = "royalnet" name = "royalnet"
version = "6.0.0a3" version = "6.0.0a4"
description = "A multipurpose bot and web framework" description = "A multipurpose bot and web framework"
authors = ["Stefano Pigozzi <ste.pigozzi@gmail.com>"] authors = ["Stefano Pigozzi <ste.pigozzi@gmail.com>"]
license = "AGPL-3.0-or-later" license = "AGPL-3.0-or-later"

View file

@ -11,7 +11,7 @@ from .exc import *
class Scroll: class Scroll:
"""A configuration handler that allows getting values from both the environment variables and a config file.""" """A configuration handler that allows getting values from both the environment variables and a config file."""
key_validator = re.compile(r"^[A-Z.]+$") key_validator = re.compile(r"^[A-Za-z.]+$")
loaders = { loaders = {
".json": json.load, ".json": json.load,
@ -55,7 +55,7 @@ class Scroll:
def _get_from_environ(self, item: str) -> JSONScalar: def _get_from_environ(self, item: str) -> JSONScalar:
"""Get a configuration value from the environment variables.""" """Get a configuration value from the environment variables."""
key = f"{self.namespace}_{item.replace('.', '_')}" key = f"{self.namespace}_{item.replace('.', '_')}".upper()
try: try:
j = os.environ[key] j = os.environ[key]
@ -74,7 +74,7 @@ class Scroll:
if self.config is None: if self.config is None:
raise NotFoundError("No config file has been loaded.") raise NotFoundError("No config file has been loaded.")
chain = item.split(".") chain = item.lower().split(".")
current = self.config current = self.config
@ -86,7 +86,7 @@ class Scroll:
return current return current
def __getattribute__(self, item: str): def __getitem__(self, item: str):
self._validate_key(item) self._validate_key(item)
try: try:
return self._get_from_environ(item) return self._get_from_environ(item)