python-simpleconf 0.9.2__tar.gz → 0.9.3__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.
- python_simpleconf-0.9.3/.coveragerc +6 -0
- python_simpleconf-0.9.3/.github/workflows/build.yml +82 -0
- python_simpleconf-0.9.3/.gitignore +110 -0
- python_simpleconf-0.9.3/.pre-commit-config.yaml +36 -0
- python_simpleconf-0.9.3/Makefile +36 -0
- {python_simpleconf-0.9.2 → python_simpleconf-0.9.3}/PKG-INFO +22 -25
- python_simpleconf-0.9.3/docs/CHANGELOG.md +15 -0
- python_simpleconf-0.9.3/pyproject.toml +69 -0
- python_simpleconf-0.9.3/setup.py +14 -0
- {python_simpleconf-0.9.2 → python_simpleconf-0.9.3}/simpleconf/__init__.py +1 -1
- {python_simpleconf-0.9.2 → python_simpleconf-0.9.3}/simpleconf/loaders/__init__.py +3 -1
- {python_simpleconf-0.9.2 → python_simpleconf-0.9.3}/simpleconf/loaders/dict.py +1 -1
- {python_simpleconf-0.9.2 → python_simpleconf-0.9.3}/simpleconf/loaders/env.py +18 -9
- {python_simpleconf-0.9.2 → python_simpleconf-0.9.3}/simpleconf/loaders/ini.py +2 -2
- python_simpleconf-0.9.3/tests/__init__.py +0 -0
- python_simpleconf-0.9.3/tests/fixt_simpleconf.py +206 -0
- python_simpleconf-0.9.3/tests/test_caster.py +100 -0
- python_simpleconf-0.9.3/tests/test_config.py +357 -0
- python_simpleconf-0.9.3/tests/test_loaders.py +532 -0
- python_simpleconf-0.9.3/tests/test_utils.py +182 -0
- python_simpleconf-0.9.3/tox.ini +6 -0
- python_simpleconf-0.9.3/uv.lock +2586 -0
- python_simpleconf-0.9.2/pyproject.toml +0 -61
- {python_simpleconf-0.9.2 → python_simpleconf-0.9.3}/LICENSE +0 -0
- {python_simpleconf-0.9.2 → python_simpleconf-0.9.3}/README.md +0 -0
- {python_simpleconf-0.9.2 → python_simpleconf-0.9.3}/simpleconf/caster.py +0 -0
- {python_simpleconf-0.9.2 → python_simpleconf-0.9.3}/simpleconf/config.py +0 -0
- {python_simpleconf-0.9.2 → python_simpleconf-0.9.3}/simpleconf/exceptions.py +0 -0
- {python_simpleconf-0.9.2 → python_simpleconf-0.9.3}/simpleconf/loaders/json.py +0 -0
- {python_simpleconf-0.9.2 → python_simpleconf-0.9.3}/simpleconf/loaders/osenv.py +0 -0
- {python_simpleconf-0.9.2 → python_simpleconf-0.9.3}/simpleconf/loaders/toml.py +0 -0
- {python_simpleconf-0.9.2 → python_simpleconf-0.9.3}/simpleconf/loaders/yaml.py +0 -0
- {python_simpleconf-0.9.2 → python_simpleconf-0.9.3}/simpleconf/py.typed +0 -0
- {python_simpleconf-0.9.2 → python_simpleconf-0.9.3}/simpleconf/utils.py +0 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
name: Build
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
release:
|
|
6
|
+
types: [published]
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
|
|
10
|
+
build:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
strategy:
|
|
13
|
+
fail-fast: false
|
|
14
|
+
matrix:
|
|
15
|
+
python-version: [3.9, "3.10", 3.11, 3.12]
|
|
16
|
+
|
|
17
|
+
steps:
|
|
18
|
+
- uses: actions/checkout@v6
|
|
19
|
+
- name: Install uv
|
|
20
|
+
uses: astral-sh/setup-uv@v5
|
|
21
|
+
with:
|
|
22
|
+
enable-cache: true
|
|
23
|
+
python-version: ${{ matrix.python-version }}
|
|
24
|
+
- name: Install dependencies
|
|
25
|
+
run: uv sync --all-extras
|
|
26
|
+
- name: Run flake8
|
|
27
|
+
run: uv run flake8 simpleconf
|
|
28
|
+
- name: Test with pytest
|
|
29
|
+
run: uv run pytest tests/ --junitxml=junit/test-results-ubuntu-${{ matrix.python-version }}.xml
|
|
30
|
+
- name: Upload pytest test results
|
|
31
|
+
uses: actions/upload-artifact@v4
|
|
32
|
+
with:
|
|
33
|
+
name: pytest-results-ubuntu-${{ matrix.python-version }}
|
|
34
|
+
path: junit/test-results-ubuntu-${{ matrix.python-version }}.xml
|
|
35
|
+
# Use always() to always run this step to publish test results when there are test failures
|
|
36
|
+
if: ${{ always() }}
|
|
37
|
+
- name: Run codacy-coverage-reporter
|
|
38
|
+
uses: codacy/codacy-coverage-reporter-action@master
|
|
39
|
+
if: matrix.python-version == 3.12
|
|
40
|
+
with:
|
|
41
|
+
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
|
|
42
|
+
coverage-reports: cov.xml
|
|
43
|
+
|
|
44
|
+
build-windows:
|
|
45
|
+
runs-on: windows-latest
|
|
46
|
+
strategy:
|
|
47
|
+
fail-fast: false
|
|
48
|
+
matrix:
|
|
49
|
+
python-version: [3.9, "3.10", 3.11, 3.12]
|
|
50
|
+
|
|
51
|
+
steps:
|
|
52
|
+
- uses: actions/checkout@v6
|
|
53
|
+
- name: Install uv
|
|
54
|
+
uses: astral-sh/setup-uv@v5
|
|
55
|
+
with:
|
|
56
|
+
enable-cache: true
|
|
57
|
+
python-version: ${{ matrix.python-version }}
|
|
58
|
+
- name: Install dependencies
|
|
59
|
+
run: uv sync --all-extras
|
|
60
|
+
- name: Run flake8
|
|
61
|
+
run: uv run flake8 simpleconf
|
|
62
|
+
- name: Test with pytest
|
|
63
|
+
run: uv run pytest tests/ --junitxml=junit/test-results-windows-${{ matrix.python-version }}.xml
|
|
64
|
+
- name: Upload pytest test results
|
|
65
|
+
uses: actions/upload-artifact@v4
|
|
66
|
+
with:
|
|
67
|
+
name: pytest-results-windows-${{ matrix.python-version }}
|
|
68
|
+
path: junit/test-results-windows-${{ matrix.python-version }}.xml
|
|
69
|
+
# Use always() to always run this step to publish test results when there are test failures
|
|
70
|
+
if: ${{ always() }}
|
|
71
|
+
|
|
72
|
+
deploy:
|
|
73
|
+
needs: [build, build-windows]
|
|
74
|
+
runs-on: ubuntu-latest
|
|
75
|
+
if: github.event_name == 'release'
|
|
76
|
+
steps:
|
|
77
|
+
- uses: actions/checkout@v6
|
|
78
|
+
- name: Install uv
|
|
79
|
+
uses: astral-sh/setup-uv@v5
|
|
80
|
+
- name: Publish to PyPI
|
|
81
|
+
run: uv build && uv publish --token ${{ secrets.PYPI_PASSWORD }}
|
|
82
|
+
if: success()
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
*.egg-info/
|
|
24
|
+
.installed.cfg
|
|
25
|
+
*.egg
|
|
26
|
+
MANIFEST
|
|
27
|
+
|
|
28
|
+
# PyInstaller
|
|
29
|
+
# Usually these files are written by a python script from a template
|
|
30
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
31
|
+
*.manifest
|
|
32
|
+
*.spec
|
|
33
|
+
|
|
34
|
+
# Installer logs
|
|
35
|
+
pip-log.txt
|
|
36
|
+
pip-delete-this-directory.txt
|
|
37
|
+
|
|
38
|
+
# Unit test / coverage reports
|
|
39
|
+
htmlcov/
|
|
40
|
+
.tox/
|
|
41
|
+
.coverage
|
|
42
|
+
.coverage.*
|
|
43
|
+
cov.xml
|
|
44
|
+
.cache
|
|
45
|
+
nosetests.xml
|
|
46
|
+
coverage.xml
|
|
47
|
+
*.cover
|
|
48
|
+
.hypothesis/
|
|
49
|
+
.pytest_cache/
|
|
50
|
+
|
|
51
|
+
# Translations
|
|
52
|
+
*.mo
|
|
53
|
+
*.pot
|
|
54
|
+
|
|
55
|
+
# Django stuff:
|
|
56
|
+
*.log
|
|
57
|
+
local_settings.py
|
|
58
|
+
db.sqlite3
|
|
59
|
+
|
|
60
|
+
# Flask stuff:
|
|
61
|
+
instance/
|
|
62
|
+
.webassets-cache
|
|
63
|
+
|
|
64
|
+
# Scrapy stuff:
|
|
65
|
+
.scrapy
|
|
66
|
+
|
|
67
|
+
# Sphinx documentation
|
|
68
|
+
docs/_build/
|
|
69
|
+
|
|
70
|
+
# PyBuilder
|
|
71
|
+
target/
|
|
72
|
+
|
|
73
|
+
# Jupyter Notebook
|
|
74
|
+
.ipynb_checkpoints
|
|
75
|
+
|
|
76
|
+
# pyenv
|
|
77
|
+
.python-version
|
|
78
|
+
|
|
79
|
+
# celery beat schedule file
|
|
80
|
+
celerybeat-schedule
|
|
81
|
+
|
|
82
|
+
# SageMath parsed files
|
|
83
|
+
*.sage.py
|
|
84
|
+
|
|
85
|
+
# Environments
|
|
86
|
+
.env
|
|
87
|
+
.venv
|
|
88
|
+
env/
|
|
89
|
+
venv/
|
|
90
|
+
ENV/
|
|
91
|
+
env.bak/
|
|
92
|
+
venv.bak/
|
|
93
|
+
|
|
94
|
+
# Spyder project settings
|
|
95
|
+
.spyderproject
|
|
96
|
+
.spyproject
|
|
97
|
+
|
|
98
|
+
# Rope project settings
|
|
99
|
+
.ropeproject
|
|
100
|
+
|
|
101
|
+
# mkdocs documentation
|
|
102
|
+
/site
|
|
103
|
+
|
|
104
|
+
# mypy
|
|
105
|
+
.mypy_cache/
|
|
106
|
+
|
|
107
|
+
*.bak
|
|
108
|
+
|
|
109
|
+
.vscode/
|
|
110
|
+
debug.ipynb
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
fail_fast: true
|
|
2
|
+
repos:
|
|
3
|
+
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
4
|
+
rev: 5df1a4bf6f04a1ed3a643167b38d502575e29aef
|
|
5
|
+
hooks:
|
|
6
|
+
- id: trailing-whitespace
|
|
7
|
+
- id: end-of-file-fixer
|
|
8
|
+
- id: check-yaml
|
|
9
|
+
exclude: 'mkdocs.yml'
|
|
10
|
+
- repo: local
|
|
11
|
+
hooks:
|
|
12
|
+
- id: flake8
|
|
13
|
+
name: Run flake8
|
|
14
|
+
files: ^simpleconf/.+\.py$
|
|
15
|
+
pass_filenames: true
|
|
16
|
+
entry: flake8
|
|
17
|
+
types: [python]
|
|
18
|
+
language: system
|
|
19
|
+
- id: versionchecker
|
|
20
|
+
name: Check version agreement in pyproject and __version__
|
|
21
|
+
entry: bash -c
|
|
22
|
+
language: system
|
|
23
|
+
args:
|
|
24
|
+
- get_ver() { echo $(egrep "^__version|^version" $1 | cut -d= -f2 | sed 's/\"\| //g'); };
|
|
25
|
+
v1=`get_ver pyproject.toml`;
|
|
26
|
+
v2=`get_ver simpleconf/__init__.py`;
|
|
27
|
+
if [[ $v1 == $v2 ]]; then exit 0; else exit 1; fi
|
|
28
|
+
pass_filenames: false
|
|
29
|
+
files: ^pyproject\.toml|simpleconf/__init__\.py$
|
|
30
|
+
- id: pytest
|
|
31
|
+
name: Run pytest
|
|
32
|
+
entry: pytest
|
|
33
|
+
language: system
|
|
34
|
+
args: [tests/]
|
|
35
|
+
pass_filenames: false
|
|
36
|
+
files: ^tests/.+$|simpleconf/.+\.py$
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
SHELL=/bin/bash
|
|
2
|
+
|
|
3
|
+
version:
|
|
4
|
+
@if [ -z "$(word 2,$(MAKECMDGOALS))" ]; then \
|
|
5
|
+
CURRENT_VERSION=$$(grep '^__version__' simpleconf/__init__.py | sed 's/__version__ = "\(.*\)"/\1/'); \
|
|
6
|
+
MAJOR=$$(echo $$CURRENT_VERSION | cut -d. -f1); \
|
|
7
|
+
MINOR=$$(echo $$CURRENT_VERSION | cut -d. -f2); \
|
|
8
|
+
PATCH=$$(echo $$CURRENT_VERSION | cut -d. -f3); \
|
|
9
|
+
NEW_PATCH=$$((PATCH + 1)); \
|
|
10
|
+
NEW_VERSION="$$MAJOR.$$MINOR.$$NEW_PATCH"; \
|
|
11
|
+
else \
|
|
12
|
+
NEW_VERSION="$(word 2,$(MAKECMDGOALS))"; \
|
|
13
|
+
fi; \
|
|
14
|
+
echo "Updating version to $$NEW_VERSION"; \
|
|
15
|
+
sed -i "s/^version = .*/version = \"$$NEW_VERSION\"/" pyproject.toml; \
|
|
16
|
+
sed -i "s/^__version__ = .*/__version__ = \"$$NEW_VERSION\"/" simpleconf/__init__.py; \
|
|
17
|
+
LAST_TAG=$$(git describe --tags --abbrev=0 2>/dev/null || echo ""); \
|
|
18
|
+
if [ -z "$$LAST_TAG" ]; then \
|
|
19
|
+
COMMITS=$$(git log --pretty=format:"- %s" HEAD); \
|
|
20
|
+
else \
|
|
21
|
+
COMMITS=$$(git log --pretty=format:"- %s" $$LAST_TAG..HEAD); \
|
|
22
|
+
fi; \
|
|
23
|
+
if [ -n "$$COMMITS" ]; then \
|
|
24
|
+
printf "\n## %s\n\n%s\n\n" "$$NEW_VERSION" "$$COMMITS" | cat - <(tail -n +3 docs/CHANGELOG.md) > docs/CHANGELOG.md.tmp; \
|
|
25
|
+
head -n 2 docs/CHANGELOG.md > docs/CHANGELOG.md.new; \
|
|
26
|
+
cat docs/CHANGELOG.md.tmp >> docs/CHANGELOG.md.new; \
|
|
27
|
+
mv docs/CHANGELOG.md.new docs/CHANGELOG.md; \
|
|
28
|
+
rm -f docs/CHANGELOG.md.tmp; \
|
|
29
|
+
fi; \
|
|
30
|
+
echo "Version updated to $$NEW_VERSION";
|
|
31
|
+
|
|
32
|
+
# Catch-all rule to ignore version number argument
|
|
33
|
+
%:
|
|
34
|
+
@:
|
|
35
|
+
|
|
36
|
+
.PHONY: version
|
|
@@ -1,41 +1,38 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: python-simpleconf
|
|
3
|
-
Version: 0.9.
|
|
3
|
+
Version: 0.9.3
|
|
4
4
|
Summary: Simple configuration management with python.
|
|
5
|
+
Project-URL: Homepage, https://github.com/pwwang/simpleconf
|
|
6
|
+
Project-URL: Repository, https://github.com/pwwang/simpleconf
|
|
7
|
+
Author-email: pwwang <pwwang@pwwang.com>
|
|
5
8
|
License: MIT
|
|
6
9
|
License-File: LICENSE
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
Requires-
|
|
10
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
-
Classifier: Programming Language :: Python :: 3
|
|
12
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
13
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
14
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
-
Classifier: Programming Language :: Python :: 3.13
|
|
17
|
-
Classifier: Programming Language :: Python :: 3.14
|
|
10
|
+
Requires-Python: >=3.9
|
|
11
|
+
Requires-Dist: diot<0.4,>=0.3.3
|
|
12
|
+
Requires-Dist: panpath<0.5,>=0.4.8
|
|
18
13
|
Provides-Extra: all
|
|
14
|
+
Requires-Dist: iniconfig<3,>=2.0; extra == 'all'
|
|
15
|
+
Requires-Dist: python-dotenv<2,>=1.1; extra == 'all'
|
|
16
|
+
Requires-Dist: pyyaml<7,>=6; extra == 'all'
|
|
17
|
+
Requires-Dist: rtoml<0.13,>=0.12; (sys_platform == 'linux') and extra == 'all'
|
|
18
|
+
Requires-Dist: tomli<3,>=2.0; (sys_platform != 'linux') and extra == 'all'
|
|
19
19
|
Provides-Extra: async
|
|
20
|
+
Requires-Dist: aiofiles>=23.0.0; extra == 'async'
|
|
20
21
|
Provides-Extra: env
|
|
22
|
+
Requires-Dist: python-dotenv<2,>=1.1; extra == 'env'
|
|
21
23
|
Provides-Extra: ini
|
|
24
|
+
Requires-Dist: iniconfig<3,>=2.0; extra == 'ini'
|
|
22
25
|
Provides-Extra: jinja2
|
|
26
|
+
Requires-Dist: jinja2<4,>=3.0; extra == 'jinja2'
|
|
23
27
|
Provides-Extra: liquid
|
|
28
|
+
Requires-Dist: liquidpy<0.9,>=0.8; extra == 'liquid'
|
|
24
29
|
Provides-Extra: liquidpy
|
|
30
|
+
Requires-Dist: liquidpy<0.9,>=0.8; extra == 'liquidpy'
|
|
25
31
|
Provides-Extra: toml
|
|
32
|
+
Requires-Dist: rtoml<0.13,>=0.12; (sys_platform == 'linux') and extra == 'toml'
|
|
33
|
+
Requires-Dist: tomli<3,>=2.0; (sys_platform != 'linux') and extra == 'toml'
|
|
26
34
|
Provides-Extra: yaml
|
|
27
|
-
Requires-Dist:
|
|
28
|
-
Requires-Dist: diot (>=0.3.3,<0.4.0)
|
|
29
|
-
Requires-Dist: iniconfig (>=2.0,<3.0) ; extra == "ini" or extra == "all"
|
|
30
|
-
Requires-Dist: jinja2 (>=3.0,<4.0) ; extra == "jinja2"
|
|
31
|
-
Requires-Dist: liquidpy (>=0.8,<0.9) ; extra == "liquid" or extra == "liquidpy"
|
|
32
|
-
Requires-Dist: panpath (>=0.4.8,<0.5.0)
|
|
33
|
-
Requires-Dist: python-dotenv (>=1.1,<2.0) ; extra == "env" or extra == "all"
|
|
34
|
-
Requires-Dist: pyyaml (>=6,<7) ; extra == "yaml" or extra == "all"
|
|
35
|
-
Requires-Dist: rtoml (>=0.12,<0.13) ; (sys_platform == "linux") and (extra == "toml" or extra == "all")
|
|
36
|
-
Requires-Dist: tomli (>=2.0,<3.0) ; (sys_platform != "linux") and (extra == "toml" or extra == "all")
|
|
37
|
-
Project-URL: Homepage, https://github.com/pwwang/simpleconf
|
|
38
|
-
Project-URL: Repository, https://github.com/pwwang/simpleconf
|
|
35
|
+
Requires-Dist: pyyaml<7,>=6; extra == 'yaml'
|
|
39
36
|
Description-Content-Type: text/markdown
|
|
40
37
|
|
|
41
38
|
# simpleconf
|
|
@@ -403,4 +400,4 @@ from simpleconf import Config
|
|
|
403
400
|
|
|
404
401
|
conf = Config.load('config.yaml')
|
|
405
402
|
# conf.default.a == 2
|
|
406
|
-
```
|
|
403
|
+
```
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# CHANGELOG
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
## 0.9.3
|
|
5
|
+
|
|
6
|
+
- style: handle bytes content and ensure safe casting in loaders
|
|
7
|
+
- chore: migrate from Poetry to Hatch for build system and dependency management
|
|
8
|
+
|
|
9
|
+
## 0.9.2
|
|
10
|
+
|
|
11
|
+
- feat: add Makefile for version management and changelog updates
|
|
12
|
+
- feat: implement loader directive detection for config files
|
|
13
|
+
- fix: add __all__ declaration for public API in __init__.py
|
|
14
|
+
- chore: update diot to 0.3.3 (implement #2)
|
|
15
|
+
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "python-simpleconf"
|
|
7
|
+
version = "0.9.3"
|
|
8
|
+
description = "Simple configuration management with python."
|
|
9
|
+
authors = [{name = "pwwang", email = "pwwang@pwwang.com"}]
|
|
10
|
+
license = {text = "MIT"}
|
|
11
|
+
readme = "README.md"
|
|
12
|
+
requires-python = ">=3.9"
|
|
13
|
+
dependencies = [
|
|
14
|
+
"diot>=0.3.3,<0.4",
|
|
15
|
+
"panpath>=0.4.8,<0.5",
|
|
16
|
+
]
|
|
17
|
+
|
|
18
|
+
[project.urls]
|
|
19
|
+
Homepage = "https://github.com/pwwang/simpleconf"
|
|
20
|
+
Repository = "https://github.com/pwwang/simpleconf"
|
|
21
|
+
|
|
22
|
+
[project.optional-dependencies]
|
|
23
|
+
ini = ["iniconfig>=2.0,<3"]
|
|
24
|
+
env = ["python-dotenv>=1.1,<2"]
|
|
25
|
+
yaml = ["pyyaml>=6,<7"]
|
|
26
|
+
# Use rtoml only when the wheel is available (linux)
|
|
27
|
+
toml = [
|
|
28
|
+
"rtoml>=0.12,<0.13; sys_platform == 'linux'",
|
|
29
|
+
"tomli>=2.0,<3; sys_platform != 'linux'",
|
|
30
|
+
]
|
|
31
|
+
async = ["aiofiles>=23.0.0"]
|
|
32
|
+
jinja2 = ["jinja2>=3.0,<4"]
|
|
33
|
+
liquid = ["liquidpy>=0.8,<0.9"]
|
|
34
|
+
liquidpy = ["liquidpy>=0.8,<0.9"]
|
|
35
|
+
all = [
|
|
36
|
+
"iniconfig>=2.0,<3",
|
|
37
|
+
"python-dotenv>=1.1,<2",
|
|
38
|
+
"pyyaml>=6,<7",
|
|
39
|
+
"rtoml>=0.12,<0.13; sys_platform == 'linux'",
|
|
40
|
+
"tomli>=2.0,<3; sys_platform != 'linux'",
|
|
41
|
+
]
|
|
42
|
+
|
|
43
|
+
[tool.hatch.build.targets.wheel]
|
|
44
|
+
packages = ["simpleconf"]
|
|
45
|
+
|
|
46
|
+
[dependency-groups]
|
|
47
|
+
dev = [
|
|
48
|
+
"pytest>=8",
|
|
49
|
+
"pytest-cov>=6",
|
|
50
|
+
"pytest-asyncio>=1",
|
|
51
|
+
"backports-asyncio-runner>=1.1.0; python_version < '3.11'",
|
|
52
|
+
"liquidpy>=0.8,<0.9",
|
|
53
|
+
"panpath[all-async]>=0.4.10",
|
|
54
|
+
"flake8>=7.3.0",
|
|
55
|
+
]
|
|
56
|
+
|
|
57
|
+
[tool.pytest.ini_options]
|
|
58
|
+
addopts = "-vv --cov=simpleconf --cov-report xml:cov.xml --cov-report term-missing"
|
|
59
|
+
filterwarnings = [
|
|
60
|
+
"error"
|
|
61
|
+
]
|
|
62
|
+
console_output_style = "progress"
|
|
63
|
+
junit_family = "xunit1"
|
|
64
|
+
asyncio_mode = "auto"
|
|
65
|
+
|
|
66
|
+
[tool.black]
|
|
67
|
+
line-length = 88
|
|
68
|
+
target-version = ['py39', 'py310', 'py311', 'py312']
|
|
69
|
+
include = '\.pyi?$'
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""
|
|
3
|
+
This will not be included in the distribution.
|
|
4
|
+
The distribution is managed by uv
|
|
5
|
+
This file is kept only for
|
|
6
|
+
1. Github to index the dependents
|
|
7
|
+
2. pip install -e .
|
|
8
|
+
Do NOT use this to install this package, unless you handled the dependencies
|
|
9
|
+
by your self:
|
|
10
|
+
pip install git+https://...
|
|
11
|
+
"""
|
|
12
|
+
from setuptools import setup
|
|
13
|
+
|
|
14
|
+
setup(name="python-simpleconf")
|
|
@@ -157,4 +157,6 @@ class LiqModifierMixin(LoaderModifierMixin):
|
|
|
157
157
|
def _modifier(self, content: str | bytes) -> str | bytes:
|
|
158
158
|
"""Modify the content of the configuration file before loading"""
|
|
159
159
|
from liquid import Liquid # type: ignore[import]
|
|
160
|
-
|
|
160
|
+
str_content = content.decode() if isinstance(content, bytes) else content
|
|
161
|
+
liq = Liquid(str_content, from_file=False, mode="wild") # type: ignore
|
|
162
|
+
return liq.render()
|
|
@@ -45,15 +45,19 @@ class EnvLoader(Loader, LoaderModifierMixin):
|
|
|
45
45
|
"""Load the configuration from a .env file"""
|
|
46
46
|
if hasattr(conf, "read"):
|
|
47
47
|
content = conf.read()
|
|
48
|
-
|
|
48
|
+
str_content = content.decode() if isinstance(content, bytes) else content
|
|
49
|
+
sio = io.StringIO(str_content) # type: ignore[arg-type]
|
|
50
|
+
return dotenv.dotenv_values(stream=sio)
|
|
49
51
|
|
|
50
52
|
if not self._exists(conf, ignore_nonexist):
|
|
51
53
|
return {}
|
|
52
54
|
|
|
53
55
|
conf = self.__class__._convert_path(conf)
|
|
54
56
|
content = conf.read_text() # so that cloud paths work
|
|
55
|
-
|
|
56
|
-
|
|
57
|
+
modified = self._modifier(content)
|
|
58
|
+
str_modified = modified.decode() if isinstance(modified, bytes) else modified
|
|
59
|
+
sio = io.StringIO(str_modified) # type: ignore[arg-type]
|
|
60
|
+
return dotenv.dotenv_values(stream=sio)
|
|
57
61
|
|
|
58
62
|
async def a_loading(self, conf, ignore_nonexist):
|
|
59
63
|
"""Asynchronously load the configuration from a .env file"""
|
|
@@ -63,16 +67,21 @@ class EnvLoader(Loader, LoaderModifierMixin):
|
|
|
63
67
|
content = await content
|
|
64
68
|
if isinstance(content, bytes):
|
|
65
69
|
content = content.decode()
|
|
66
|
-
|
|
67
|
-
|
|
70
|
+
modified = self._modifier(content)
|
|
71
|
+
str_modified = modified.decode() if isinstance(modified, bytes) else modified
|
|
72
|
+
sio = io.StringIO(str_modified) # type: ignore[arg-type]
|
|
73
|
+
return dotenv.dotenv_values(stream=sio)
|
|
68
74
|
|
|
69
75
|
if not await self._a_exists(conf, ignore_nonexist):
|
|
70
76
|
return {}
|
|
71
77
|
|
|
72
78
|
conf = self.__class__._convert_path(conf)
|
|
73
|
-
|
|
74
|
-
content =
|
|
75
|
-
|
|
79
|
+
# so that cloud paths work
|
|
80
|
+
content = await conf.a_read_text() # type: ignore[attr-defined]
|
|
81
|
+
modified = self._modifier(content)
|
|
82
|
+
str_modified = modified.decode() if isinstance(modified, bytes) else modified
|
|
83
|
+
sio = io.StringIO(str_modified) # type: ignore[arg-type]
|
|
84
|
+
return dotenv.dotenv_values(stream=sio)
|
|
76
85
|
|
|
77
86
|
@classmethod
|
|
78
87
|
def _convert_with_profiles( # type: ignore[override]
|
|
@@ -89,7 +98,7 @@ class EnvLoader(Loader, LoaderModifierMixin):
|
|
|
89
98
|
profile = profile.lower()
|
|
90
99
|
out.setdefault(profile, Diot())[key] = v
|
|
91
100
|
|
|
92
|
-
return cast(out, cls.CASTERS)
|
|
101
|
+
return cast(out, cls.CASTERS or [])
|
|
93
102
|
|
|
94
103
|
|
|
95
104
|
class EnvsLoader(NoConvertingPathMixin, EnvLoader): # type: ignore[misc]
|
|
@@ -99,7 +99,7 @@ class IniLoader(Loader, LoaderModifierMixin):
|
|
|
99
99
|
if len(keys) == 0 or keys[0].lower() != "default":
|
|
100
100
|
raise ValueError(f"{pathname}: Only the default section can be loaded.")
|
|
101
101
|
|
|
102
|
-
return cast(Diot(loaded[keys[0]]), cls.CASTERS)
|
|
102
|
+
return cast(Diot(loaded[keys[0]]), cls.CASTERS or [])
|
|
103
103
|
|
|
104
104
|
@classmethod
|
|
105
105
|
def _convert_with_profiles( # type: ignore[override]
|
|
@@ -109,7 +109,7 @@ class IniLoader(Loader, LoaderModifierMixin):
|
|
|
109
109
|
) -> Diot:
|
|
110
110
|
out = Diot()
|
|
111
111
|
for k, v in loaded.items():
|
|
112
|
-
out[k.lower()] = cast(v, cls.CASTERS)
|
|
112
|
+
out[k.lower()] = cast(v, cls.CASTERS or [])
|
|
113
113
|
return out
|
|
114
114
|
|
|
115
115
|
|
|
File without changes
|