mooch.settings 0.0.1.dev2__py3-none-any.whl → 0.0.1.dev4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mooch/settings/__init__.py +2 -3
- mooch/settings/{file.py → filehandler.py} +1 -1
- mooch/settings/settings.py +16 -11
- {mooch_settings-0.0.1.dev2.dist-info → mooch_settings-0.0.1.dev4.dist-info}/METADATA +6 -2
- mooch_settings-0.0.1.dev4.dist-info/RECORD +10 -0
- mooch_settings-0.0.1.dev2.dist-info/RECORD +0 -10
- {mooch_settings-0.0.1.dev2.dist-info → mooch_settings-0.0.1.dev4.dist-info}/WHEEL +0 -0
- {mooch_settings-0.0.1.dev2.dist-info → mooch_settings-0.0.1.dev4.dist-info}/licenses/LICENSE +0 -0
- {mooch_settings-0.0.1.dev2.dist-info → mooch_settings-0.0.1.dev4.dist-info}/top_level.txt +0 -0
mooch/settings/__init__.py
CHANGED
mooch/settings/settings.py
CHANGED
@@ -3,7 +3,7 @@ from __future__ import annotations
|
|
3
3
|
from pathlib import Path
|
4
4
|
from typing import Any
|
5
5
|
|
6
|
-
from mooch.settings.
|
6
|
+
from mooch.settings.filehandler import FileHandler
|
7
7
|
from mooch.settings.utils import get_nested, set_nested
|
8
8
|
|
9
9
|
|
@@ -12,9 +12,19 @@ class Settings:
|
|
12
12
|
self,
|
13
13
|
settings_filepath: Path,
|
14
14
|
default_settings: dict | None = None,
|
15
|
+
*,
|
16
|
+
dynamic_reload: bool = True,
|
15
17
|
) -> None:
|
16
|
-
|
17
|
-
|
18
|
+
if not isinstance(settings_filepath, Path):
|
19
|
+
error_message = "settings_filepath must be a Path object"
|
20
|
+
raise TypeError(error_message)
|
21
|
+
if not isinstance(default_settings, dict) and default_settings is not None:
|
22
|
+
error_message = "default_settings must be a dictionary or None"
|
23
|
+
raise TypeError(error_message)
|
24
|
+
|
25
|
+
self._settings_filepath = settings_filepath
|
26
|
+
self._file = FileHandler(self._settings_filepath)
|
27
|
+
self.dynamic_reload = dynamic_reload
|
18
28
|
|
19
29
|
self._data = self._file.load()
|
20
30
|
|
@@ -22,14 +32,6 @@ class Settings:
|
|
22
32
|
self._set_defaults(default_settings)
|
23
33
|
self._file.save(self._data)
|
24
34
|
|
25
|
-
@staticmethod
|
26
|
-
def home_directory() -> Path:
|
27
|
-
"""Return the path to the home directory.
|
28
|
-
|
29
|
-
Returns: Path
|
30
|
-
"""
|
31
|
-
return Path.home()
|
32
|
-
|
33
35
|
def get(self, key: str) -> Any | None: # noqa: ANN401
|
34
36
|
"""Return a value from the configuration by key.
|
35
37
|
|
@@ -74,3 +76,6 @@ class Settings:
|
|
74
76
|
|
75
77
|
elif isinstance(v, dict):
|
76
78
|
self._set_defaults(v, full_key)
|
79
|
+
|
80
|
+
def __repr__(self) -> str: # noqa: D105
|
81
|
+
return f"Settings Stored at: {self._settings_filepath}"
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: mooch.settings
|
3
|
-
Version: 0.0.1.
|
3
|
+
Version: 0.0.1.dev4
|
4
4
|
Summary: Python settings management package (mooch.settings). Uses a TOML file.
|
5
5
|
Author-email: Nick Stuer <nickstuer@duck.com>
|
6
6
|
Project-URL: Homepage, https://github.com/nickstuer/mooch.settings
|
@@ -21,6 +21,10 @@ Dynamic: license-file
|
|
21
21
|

|
22
22
|
<img alt="GitHub Issues or Pull Requests" src="https://img.shields.io/github/issues/nickstuer/mooch.settings">
|
23
23
|
|
24
|
+

|
25
|
+

|
26
|
+

|
27
|
+
|
24
28
|
[](https://github.com/RichardLitt/standard-readme)
|
25
29
|
[](LICENSE)
|
26
30
|
|
@@ -38,7 +42,7 @@ This Python package is a collection of useful Python code that is commonly used
|
|
38
42
|
|
39
43
|
|
40
44
|
### Settings File
|
41
|
-
Uses a TOML settings file. Easily get/set
|
45
|
+
Uses a TOML settings file. Easily get/set settings values. Automatically sets values to defaults if they're not currently saved in the setting file.
|
42
46
|
|
43
47
|
|
44
48
|
## 🛠 Install
|
@@ -0,0 +1,10 @@
|
|
1
|
+
mooch/__init__.py,sha256=_ZVUSDxucTCJe9q2wP1tI31qEX3m4QGcH7kn3BRv6ic,112
|
2
|
+
mooch/settings/__init__.py,sha256=D5YbYh6gPIJXOwYlX0FDTRLDoUu0wfnJd1jdvh59ju0,83
|
3
|
+
mooch/settings/filehandler.py,sha256=X3_kFcCtoJt3yI5v_r4GEKaoQIpimlwFPQxYPP5UKPE,1503
|
4
|
+
mooch/settings/settings.py,sha256=zN6l-8amrrm66h8afOvifv-WdgObpHVlUIEzEs9mN3g,2603
|
5
|
+
mooch/settings/utils.py,sha256=V-aFKlrLaDfuJed4Yn-1pxlIM8jzdr4xRrNflBxLfXc,665
|
6
|
+
mooch_settings-0.0.1.dev4.dist-info/licenses/LICENSE,sha256=FU8uKPcPjgV4M_aaYQPSM5abrktGqLFX2VEUk9oBYIE,1067
|
7
|
+
mooch_settings-0.0.1.dev4.dist-info/METADATA,sha256=saXexWmtLe3kfExxjGVRDIFLkhHuLG2pBVl46fp4MA4,3308
|
8
|
+
mooch_settings-0.0.1.dev4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
9
|
+
mooch_settings-0.0.1.dev4.dist-info/top_level.txt,sha256=BbCxYfdneRNeyhPyAVvt8IEDA_Px7BIm5zhH6hEmsAo,6
|
10
|
+
mooch_settings-0.0.1.dev4.dist-info/RECORD,,
|
@@ -1,10 +0,0 @@
|
|
1
|
-
mooch/__init__.py,sha256=_ZVUSDxucTCJe9q2wP1tI31qEX3m4QGcH7kn3BRv6ic,112
|
2
|
-
mooch/settings/__init__.py,sha256=Vs0DYdXwvsEU21Umpj893RoX2iSrL7n4Qb-5X4GYtiI,69
|
3
|
-
mooch/settings/file.py,sha256=Q3lpANh8bvhZZ3iEGeQ7zpOn5Q7-7t6ZZbPZelv9NlM,1496
|
4
|
-
mooch/settings/settings.py,sha256=fL229LnQjte7UP5_cMFaM1YnqKh7LLV8sgWJkgW18jk,2152
|
5
|
-
mooch/settings/utils.py,sha256=V-aFKlrLaDfuJed4Yn-1pxlIM8jzdr4xRrNflBxLfXc,665
|
6
|
-
mooch_settings-0.0.1.dev2.dist-info/licenses/LICENSE,sha256=FU8uKPcPjgV4M_aaYQPSM5abrktGqLFX2VEUk9oBYIE,1067
|
7
|
-
mooch_settings-0.0.1.dev2.dist-info/METADATA,sha256=J6cril1SRUnV49K_si062bA10B8VR_AVY3qf7wDzozE,2999
|
8
|
-
mooch_settings-0.0.1.dev2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
9
|
-
mooch_settings-0.0.1.dev2.dist-info/top_level.txt,sha256=BbCxYfdneRNeyhPyAVvt8IEDA_Px7BIm5zhH6hEmsAo,6
|
10
|
-
mooch_settings-0.0.1.dev2.dist-info/RECORD,,
|
File without changes
|
{mooch_settings-0.0.1.dev2.dist-info → mooch_settings-0.0.1.dev4.dist-info}/licenses/LICENSE
RENAMED
File without changes
|
File without changes
|