bluerobotics / bluerobotics/BlueOS
Core: commonwealth: settings lib returns valid settings when loading from an inexistent file
- Dominant language
- Vue
- Stars
- 453
- Forks
- 151
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 174
Description
```
import json
import re
import socket
from typing import Any, Dict
import psutil
from commonwealth.settings import settings
from commonwealth.settings.manager import Manager
class SettingsV1(settings.BaseSettings):
VERSION = 1
def __init__(self, *args: str, **kwargs: int) -> None:
super().__init__(*args, **kwargs)
self.VERSION = SettingsV1.VERSION
def migrate(self, data: Dict[str, Any]) -> None:
if data["VERSION"] == SettingsV1.VERSION:
return
if data["VERSION"] < SettingsV1.VERSION:
super().migrate(data)
data["VERSION"] = SettingsV1.VERSION
manager = Manager("Biscoito", SettingsV1)
manager.load()
print(manager.settings)
```
```
2022-03-19 17:12:33.345 | DEBUG | commonwealth.settings.manager:__init__:33 - Starting Biscoito settings with SettingsV1, configuration path: None
2022-03-19 17:12:33.345 | DEBUG | commonwealth.settings.manager:load:115 - Found possible candidates for settings source: []
2022-03-19 17:12:33.345 | DEBUG | commonwealth.settings.settings:save:93 - Saving settings on: /home/will/.config/Biscoito/settings-1.json
2022-03-19 17:12:33.345 | DEBUG | commonwealth.settings.manager:load:115 - Found possible candidates for settings source: [PosixPath('/home/will/.config/Biscoito/settings-1.json')]
2022-03-19 17:12:33.346 | DEBUG | commonwealth.settings.manager:load:117 - Checking /home/will/.config/Biscoito/settings-1.json for settings
2022-03-19 17:12:33.346 | DEBUG | commonwealth.settings.settings:load:53 - Loading settings from file: /home/will/.config/Biscoito/settings-1.json
2022-03-19 17:12:33.346 | DEBUG | commonwealth.settings.manager:load:120 - Using /home/will/.config/Biscoito/settings-1.json as settings source
{
"VERSION": 1
}
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.