antares-dotenv 1.0.0__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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Antares
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,19 @@
1
+ Metadata-Version: 2.1
2
+ Name: antares-dotenv
3
+ Version: 1.0.0
4
+ Summary: A minimal utility to load environment variables with automatic type casting.
5
+ License: MIT
6
+ Author: Antares Mugisho
7
+ Author-email: antaresmugisho@gmail.com
8
+ Requires-Python: >=3.11,<4.0
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3.11
12
+ Requires-Dist: python-dotenv (>=1.1.0,<2.0.0)
13
+ Description-Content-Type: text/markdown
14
+
15
+ # My Dotenv
16
+
17
+ A minimal utility to load environment variables with automatic type casting (bool, list, int, float, JSON).
18
+
19
+ __For personnal use__
@@ -0,0 +1,5 @@
1
+ # My Dotenv
2
+
3
+ A minimal utility to load environment variables with automatic type casting (bool, list, int, float, JSON).
4
+
5
+ __For personnal use__
@@ -0,0 +1,3 @@
1
+ from .core import env
2
+
3
+ __all__ = ["env"]
@@ -0,0 +1,45 @@
1
+ import os
2
+ import json
3
+ from typing import Any
4
+ from dotenv import load_dotenv
5
+
6
+ load_dotenv()
7
+
8
+ def _parse_value(value: str) -> Any:
9
+ value = value.strip()
10
+
11
+ # Boolean
12
+ if value.lower() in ("true", "false"):
13
+ return value.lower() == "true"
14
+
15
+
16
+ # Integer
17
+ if value.isdigit():
18
+ return int(value)
19
+
20
+ # Float
21
+ try:
22
+ float_val = float(value)
23
+ return float_val
24
+ except ValueError:
25
+ pass
26
+
27
+ # JSON (The order is important: JSON first then List)
28
+ try:
29
+ return json.loads(value)
30
+ except (json.JSONDecodeError, TypeError):
31
+ pass
32
+
33
+ # List (comma-separated)
34
+ if "," in value and not value.startswith("["):
35
+ return [_parse_value(item) for item in value.split(',')]
36
+
37
+ # Fallback to string
38
+ return value
39
+
40
+
41
+ def env(key: str, default: Any = None) -> Any:
42
+ value = os.getenv(key)
43
+ if value is None:
44
+ return default
45
+ return _parse_value(value)
@@ -0,0 +1,15 @@
1
+ [tool.poetry]
2
+ name = "antares-dotenv"
3
+ version = "1.0.0"
4
+ description = "A minimal utility to load environment variables with automatic type casting."
5
+ authors = ["Antares Mugisho <antaresmugisho@gmail.com>"]
6
+ license = "MIT"
7
+ readme = "README.md"
8
+
9
+ [tool.poetry.dependencies]
10
+ python = "^3.11"
11
+ python-dotenv = "^1.1.0"
12
+
13
+ [build-system]
14
+ requires = ["poetry-core"]
15
+ build-backend = "poetry.core.masonry.api"
@@ -0,0 +1,30 @@
1
+ # -*- coding: utf-8 -*-
2
+ from setuptools import setup
3
+
4
+ packages = \
5
+ ['antares_dotenv']
6
+
7
+ package_data = \
8
+ {'': ['*']}
9
+
10
+ install_requires = \
11
+ ['python-dotenv>=1.1.0,<2.0.0']
12
+
13
+ setup_kwargs = {
14
+ 'name': 'antares-dotenv',
15
+ 'version': '1.0.0',
16
+ 'description': 'A minimal utility to load environment variables with automatic type casting.',
17
+ 'long_description': '# My Dotenv\n\nA minimal utility to load environment variables with automatic type casting (bool, list, int, float, JSON).\n\n__For personnal use__',
18
+ 'author': 'Antares Mugisho',
19
+ 'author_email': 'antaresmugisho@gmail.com',
20
+ 'maintainer': 'None',
21
+ 'maintainer_email': 'None',
22
+ 'url': 'None',
23
+ 'packages': packages,
24
+ 'package_data': package_data,
25
+ 'install_requires': install_requires,
26
+ 'python_requires': '>=3.11,<4.0',
27
+ }
28
+
29
+
30
+ setup(**setup_kwargs)