mooch.settings 0.0.1.dev2__tar.gz → 0.0.1.dev3__tar.gz
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-0.0.1.dev3/.github/workflows/run_tests.yml +51 -0
- {mooch_settings-0.0.1.dev2/src/mooch.settings.egg-info → mooch_settings-0.0.1.dev3}/PKG-INFO +6 -2
- {mooch_settings-0.0.1.dev2 → mooch_settings-0.0.1.dev3}/README.md +5 -1
- {mooch_settings-0.0.1.dev2 → mooch_settings-0.0.1.dev3}/pyproject.toml +1 -1
- mooch_settings-0.0.1.dev3/src/mooch/settings/__init__.py +3 -0
- mooch_settings-0.0.1.dev2/src/mooch/settings/file.py → mooch_settings-0.0.1.dev3/src/mooch/settings/filehandler.py +1 -1
- {mooch_settings-0.0.1.dev2 → mooch_settings-0.0.1.dev3}/src/mooch/settings/settings.py +16 -11
- {mooch_settings-0.0.1.dev2 → mooch_settings-0.0.1.dev3/src/mooch.settings.egg-info}/PKG-INFO +6 -2
- {mooch_settings-0.0.1.dev2 → mooch_settings-0.0.1.dev3}/src/mooch.settings.egg-info/SOURCES.txt +2 -1
- {mooch_settings-0.0.1.dev2 → mooch_settings-0.0.1.dev3}/tests/test_file.py +6 -6
- {mooch_settings-0.0.1.dev2 → mooch_settings-0.0.1.dev3}/tests/test_settings.py +38 -11
- mooch_settings-0.0.1.dev2/src/mooch/settings/__init__.py +0 -4
- {mooch_settings-0.0.1.dev2 → mooch_settings-0.0.1.dev3}/.gitignore +0 -0
- {mooch_settings-0.0.1.dev2 → mooch_settings-0.0.1.dev3}/LICENSE +0 -0
- {mooch_settings-0.0.1.dev2 → mooch_settings-0.0.1.dev3}/settings.toml +0 -0
- {mooch_settings-0.0.1.dev2 → mooch_settings-0.0.1.dev3}/setup.cfg +0 -0
- {mooch_settings-0.0.1.dev2 → mooch_settings-0.0.1.dev3}/src/mooch/__init__.py +0 -0
- {mooch_settings-0.0.1.dev2 → mooch_settings-0.0.1.dev3}/src/mooch/settings/utils.py +0 -0
- {mooch_settings-0.0.1.dev2 → mooch_settings-0.0.1.dev3}/src/mooch.settings.egg-info/dependency_links.txt +0 -0
- {mooch_settings-0.0.1.dev2 → mooch_settings-0.0.1.dev3}/src/mooch.settings.egg-info/requires.txt +0 -0
- {mooch_settings-0.0.1.dev2 → mooch_settings-0.0.1.dev3}/src/mooch.settings.egg-info/top_level.txt +0 -0
- {mooch_settings-0.0.1.dev2 → mooch_settings-0.0.1.dev3}/tests/test_utils.py +0 -0
- {mooch_settings-0.0.1.dev2 → mooch_settings-0.0.1.dev3}/uv.lock +0 -0
@@ -0,0 +1,51 @@
|
|
1
|
+
name: Run Tests and Upload Coverage
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [main]
|
6
|
+
pull_request:
|
7
|
+
branches: [main]
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
test:
|
11
|
+
runs-on: ${{ matrix.os }}
|
12
|
+
strategy:
|
13
|
+
matrix:
|
14
|
+
os: [ubuntu-latest, macos-latest, windows-latest]
|
15
|
+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
|
16
|
+
env:
|
17
|
+
OS: ${{ matrix.os }}
|
18
|
+
PYTHON: ${{ matrix.python-version }}
|
19
|
+
|
20
|
+
steps:
|
21
|
+
- name: Checkout code
|
22
|
+
uses: actions/checkout@v4
|
23
|
+
|
24
|
+
- name: Set up Python ${{ matrix.python-version }}
|
25
|
+
uses: actions/setup-python@v5
|
26
|
+
with:
|
27
|
+
python-version: ${{ matrix.python-version }}
|
28
|
+
|
29
|
+
- name: Install the latest version of uv
|
30
|
+
uses: astral-sh/setup-uv@v6
|
31
|
+
|
32
|
+
|
33
|
+
- name: Install dependencies
|
34
|
+
run: uv pip install --system . pytest pytest-cov
|
35
|
+
|
36
|
+
- name: Run tests with coverage
|
37
|
+
run: |
|
38
|
+
pytest --cov=./ --cov-report=xml
|
39
|
+
|
40
|
+
- name: Upload coverage to Codecov
|
41
|
+
uses: codecov/codecov-action@v5
|
42
|
+
with:
|
43
|
+
directory: ./coverage/reports/
|
44
|
+
env_vars: OS,PYTHON
|
45
|
+
fail_ci_if_error: true
|
46
|
+
files: ./coverage.xml,!./cache
|
47
|
+
flags: unittests
|
48
|
+
name: codecov-umbrella
|
49
|
+
token: ${{ secrets.CODECOV_TOKEN }}
|
50
|
+
verbose: true
|
51
|
+
|
{mooch_settings-0.0.1.dev2/src/mooch.settings.egg-info → mooch_settings-0.0.1.dev3}/PKG-INFO
RENAMED
@@ -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.dev3
|
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
|
@@ -4,6 +4,10 @@
|
|
4
4
|

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

|
8
|
+

|
9
|
+

|
10
|
+
|
7
11
|
[](https://github.com/RichardLitt/standard-readme)
|
8
12
|
[](LICENSE)
|
9
13
|
|
@@ -21,7 +25,7 @@ This Python package is a collection of useful Python code that is commonly used
|
|
21
25
|
|
22
26
|
|
23
27
|
### Settings File
|
24
|
-
Uses a TOML settings file. Easily get/set
|
28
|
+
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.
|
25
29
|
|
26
30
|
|
27
31
|
## 🛠 Install
|
@@ -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}"
|
{mooch_settings-0.0.1.dev2 → mooch_settings-0.0.1.dev3/src/mooch.settings.egg-info}/PKG-INFO
RENAMED
@@ -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.dev3
|
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
|
{mooch_settings-0.0.1.dev2 → mooch_settings-0.0.1.dev3}/src/mooch.settings.egg-info/SOURCES.txt
RENAMED
@@ -4,6 +4,7 @@ README.md
|
|
4
4
|
pyproject.toml
|
5
5
|
settings.toml
|
6
6
|
uv.lock
|
7
|
+
.github/workflows/run_tests.yml
|
7
8
|
src/mooch/__init__.py
|
8
9
|
src/mooch.settings.egg-info/PKG-INFO
|
9
10
|
src/mooch.settings.egg-info/SOURCES.txt
|
@@ -11,7 +12,7 @@ src/mooch.settings.egg-info/dependency_links.txt
|
|
11
12
|
src/mooch.settings.egg-info/requires.txt
|
12
13
|
src/mooch.settings.egg-info/top_level.txt
|
13
14
|
src/mooch/settings/__init__.py
|
14
|
-
src/mooch/settings/
|
15
|
+
src/mooch/settings/filehandler.py
|
15
16
|
src/mooch/settings/settings.py
|
16
17
|
src/mooch/settings/utils.py
|
17
18
|
tests/test_file.py
|
@@ -4,7 +4,7 @@ from pathlib import Path
|
|
4
4
|
import pytest
|
5
5
|
import toml
|
6
6
|
|
7
|
-
from mooch.settings.
|
7
|
+
from mooch.settings.filehandler import CREATED_KEY, NOTICE, UPDATED_KEY, FileHandler
|
8
8
|
|
9
9
|
|
10
10
|
@pytest.fixture
|
@@ -17,7 +17,7 @@ def temp_settings_file(tmp_path):
|
|
17
17
|
|
18
18
|
|
19
19
|
def test_create_file_if_not_exists_creates_file_with_metadata(temp_settings_file):
|
20
|
-
file =
|
20
|
+
file = FileHandler(temp_settings_file)
|
21
21
|
assert temp_settings_file.exists()
|
22
22
|
data = toml.load(temp_settings_file)
|
23
23
|
assert data["metadata"]["notice"] == NOTICE
|
@@ -26,7 +26,7 @@ def test_create_file_if_not_exists_creates_file_with_metadata(temp_settings_file
|
|
26
26
|
|
27
27
|
|
28
28
|
def test_load_returns_correct_data(temp_settings_file):
|
29
|
-
file =
|
29
|
+
file = FileHandler(temp_settings_file)
|
30
30
|
# Write some data
|
31
31
|
data = {"foo": {"bar": 123}}
|
32
32
|
file.save(data)
|
@@ -36,7 +36,7 @@ def test_load_returns_correct_data(temp_settings_file):
|
|
36
36
|
|
37
37
|
|
38
38
|
def test_save_updates_updated_timestamp(temp_settings_file):
|
39
|
-
file =
|
39
|
+
file = FileHandler(temp_settings_file)
|
40
40
|
data = file.load()
|
41
41
|
old_updated = data["metadata"]["updated"]
|
42
42
|
# Wait a moment to ensure timestamp changes
|
@@ -49,7 +49,7 @@ def test_save_updates_updated_timestamp(temp_settings_file):
|
|
49
49
|
|
50
50
|
|
51
51
|
def test_save_and_load_roundtrip(temp_settings_file):
|
52
|
-
file =
|
52
|
+
file = FileHandler(temp_settings_file)
|
53
53
|
data = {"alpha": 1, "beta": {"gamma": 2}}
|
54
54
|
file.save(data)
|
55
55
|
loaded = file.load()
|
@@ -62,7 +62,7 @@ def test_create_file_if_not_exists_does_not_overwrite_existing(temp_settings_fil
|
|
62
62
|
# Create file manually
|
63
63
|
with Path.open(temp_settings_file, "w", encoding="utf-8") as f:
|
64
64
|
f.write('[custom]\nkey="value"\n')
|
65
|
-
file =
|
65
|
+
file = FileHandler(temp_settings_file)
|
66
66
|
data = file.load()
|
67
67
|
assert "custom" in data
|
68
68
|
assert data["custom"]["key"] == "value"
|
@@ -22,8 +22,8 @@ default_settings2 = {
|
|
22
22
|
@pytest.fixture
|
23
23
|
def settings_filepath(tmpdir_factory: pytest.TempdirFactory):
|
24
24
|
temp_dir = str(tmpdir_factory.mktemp("temp"))
|
25
|
-
|
26
|
-
yield Path(
|
25
|
+
temp_testing_dir = temp_dir + "/testing/settings.toml"
|
26
|
+
yield Path(temp_testing_dir)
|
27
27
|
# yield Path("settings.toml")
|
28
28
|
shutil.rmtree(temp_dir)
|
29
29
|
|
@@ -45,6 +45,36 @@ def test_settings_initializes_with_default_settings(settings_filepath: Path):
|
|
45
45
|
assert settings.get("foo") is None
|
46
46
|
|
47
47
|
|
48
|
+
@pytest.mark.parametrize(
|
49
|
+
("value"),
|
50
|
+
[
|
51
|
+
("settings.toml"),
|
52
|
+
(523),
|
53
|
+
(None),
|
54
|
+
(["settings.toml"]),
|
55
|
+
({"settings.toml": "value"}),
|
56
|
+
],
|
57
|
+
)
|
58
|
+
def test_settings_settings_filepath_types_fails(value):
|
59
|
+
with pytest.raises(TypeError) as exc_info:
|
60
|
+
Settings(value)
|
61
|
+
assert str(exc_info.value) == "settings_filepath must be a Path object"
|
62
|
+
|
63
|
+
|
64
|
+
@pytest.mark.parametrize(
|
65
|
+
("value"),
|
66
|
+
[
|
67
|
+
("settings.toml"),
|
68
|
+
(523),
|
69
|
+
(["settings.toml"]),
|
70
|
+
],
|
71
|
+
)
|
72
|
+
def test_settings_default_settings_types_fails(value, settings_filepath):
|
73
|
+
with pytest.raises(TypeError) as exc_info:
|
74
|
+
Settings(settings_filepath, value)
|
75
|
+
assert str(exc_info.value) == "default_settings must be a dictionary or None"
|
76
|
+
|
77
|
+
|
48
78
|
def test_settings_sets_default_settings_if_not_present(settings_filepath: Path):
|
49
79
|
settings = Settings(settings_filepath, default_settings)
|
50
80
|
assert settings.get("foo") is None
|
@@ -224,13 +254,6 @@ def test_settings_sets_default_settings_of_nested_dictionaries_if_not_present(se
|
|
224
254
|
assert new_settings.get("settings.gui.theme.android") == "light"
|
225
255
|
|
226
256
|
|
227
|
-
def test_settings_home_directory():
|
228
|
-
settings = Settings(Path("settings.toml"))
|
229
|
-
home_dir = settings.home_directory()
|
230
|
-
assert home_dir.is_dir() # Check if the home directory exists
|
231
|
-
assert home_dir == Path.home() # Ensure it matches the actual home directory
|
232
|
-
|
233
|
-
|
234
257
|
def test_settings_dynamic_reload_true(settings_filepath: Path):
|
235
258
|
settings = Settings(settings_filepath, default_settings)
|
236
259
|
|
@@ -254,5 +277,9 @@ def test_settings_dynamic_reload_false(settings_filepath: Path):
|
|
254
277
|
settings2 = Settings(settings_filepath, default_settings)
|
255
278
|
settings2.set("settings.name", "NewName")
|
256
279
|
|
257
|
-
|
258
|
-
|
280
|
+
|
281
|
+
# Verify that the change is reflected in the original settings object
|
282
|
+
def test_settings_repr_returns_expected_string(settings_filepath: Path):
|
283
|
+
settings = Settings(settings_filepath, default_settings)
|
284
|
+
expected = f"Settings Stored at: {settings_filepath}"
|
285
|
+
assert repr(settings) == expected
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{mooch_settings-0.0.1.dev2 → mooch_settings-0.0.1.dev3}/src/mooch.settings.egg-info/requires.txt
RENAMED
File without changes
|
{mooch_settings-0.0.1.dev2 → mooch_settings-0.0.1.dev3}/src/mooch.settings.egg-info/top_level.txt
RENAMED
File without changes
|
File without changes
|
File without changes
|