From bf949fed553af424fba818fad14270235637ab9a Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Wed, 28 Oct 2020 19:04:45 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9E=20Fix=20scroll=20access=20and=20bu?= =?UTF-8?q?mp=20to=206.0.0a4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pyproject.toml | 2 +- royalnet/scrolls/__init__.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 07e02e2b..29fa41a7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "royalnet" -version = "6.0.0a3" +version = "6.0.0a4" description = "A multipurpose bot and web framework" authors = ["Stefano Pigozzi "] license = "AGPL-3.0-or-later" diff --git a/royalnet/scrolls/__init__.py b/royalnet/scrolls/__init__.py index 6557ff84..332e83e3 100644 --- a/royalnet/scrolls/__init__.py +++ b/royalnet/scrolls/__init__.py @@ -11,7 +11,7 @@ from .exc import * class Scroll: """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 = { ".json": json.load, @@ -55,7 +55,7 @@ class Scroll: def _get_from_environ(self, item: str) -> JSONScalar: """Get a configuration value from the environment variables.""" - key = f"{self.namespace}_{item.replace('.', '_')}" + key = f"{self.namespace}_{item.replace('.', '_')}".upper() try: j = os.environ[key] @@ -74,7 +74,7 @@ class Scroll: if self.config is None: raise NotFoundError("No config file has been loaded.") - chain = item.split(".") + chain = item.lower().split(".") current = self.config @@ -86,7 +86,7 @@ class Scroll: return current - def __getattribute__(self, item: str): + def __getitem__(self, item: str): self._validate_key(item) try: return self._get_from_environ(item)