-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate from
config.ini
to config.toml
- Loading branch information
Showing
8 changed files
with
53 additions
and
37 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
[frontend] | ||
path = "../frontend" | ||
build = "npm run build" | ||
build_path = "../public" | ||
show_output = true | ||
motd = "Memory: {{teal}}{{memory_used}} MB{{end}} / {{memory_total}} MB\nCPU: {{teal}}{{cpu_percent}}%%{{end}}\nUsers: {{teal}}{{active_users}}{{end}}\nHave a great day!" | ||
|
||
[login] | ||
disable_statuses = [] | ||
widgets = ["header", "version", "motd", "status", "sysinfo"] | ||
|
||
[status] | ||
show_output = true | ||
disable_statuses = ["npm_doct", "version", "ncu", "npm_audit"] | ||
|
||
[security] | ||
# Specify auth cookie expire time in seconds | ||
auth_cookie_expire_time = 3600.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,32 @@ | ||
from configparser import ConfigParser | ||
from typing import Any, Optional | ||
import tomllib | ||
from typing import Any, Dict, Optional | ||
import logging | ||
|
||
_config: ConfigParser = ConfigParser() | ||
|
||
class Wrapper: | ||
def __init__(self) -> None: | ||
self.config: Optional[Dict[Any, Any]] = None | ||
|
||
def set(self, config: Dict[Any, Any]) -> None: | ||
self.config = config | ||
|
||
def get(self) -> Optional[Dict[Any, Any]]: | ||
return self.config | ||
|
||
|
||
_config: Wrapper = Wrapper() | ||
|
||
|
||
def load() -> None: | ||
_config.read('config/config.ini') | ||
with open("config/config.toml", "rb") as f: | ||
_config.set(tomllib.load(f)) | ||
f.close() | ||
logging.info('Config loaded') | ||
|
||
|
||
def get(field: str) -> Optional[Any]: | ||
return _config[field] | ||
def fetch() -> Dict[Any, Any]: | ||
dict_ = _config.get() | ||
if dict_ is None: | ||
logging.critical('Config used before being loaded') | ||
return {} | ||
return dict_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters