dataconf 3.2.0__tar.gz → 3.3.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.
- {dataconf-3.2.0 → dataconf-3.3.0}/PKG-INFO +9 -13
- {dataconf-3.2.0 → dataconf-3.3.0}/README.md +3 -3
- {dataconf-3.2.0 → dataconf-3.3.0}/dataconf/exceptions.py +6 -0
- {dataconf-3.2.0 → dataconf-3.3.0}/dataconf/utils.py +5 -4
- {dataconf-3.2.0 → dataconf-3.3.0}/dataconf/version.py +1 -1
- {dataconf-3.2.0 → dataconf-3.3.0}/pyproject.toml +13 -13
- dataconf-3.2.0/setup.py +0 -38
- {dataconf-3.2.0 → dataconf-3.3.0}/LICENSE +0 -0
- {dataconf-3.2.0 → dataconf-3.3.0}/dataconf/__init__.py +0 -0
- {dataconf-3.2.0 → dataconf-3.3.0}/dataconf/cli.py +0 -0
- {dataconf-3.2.0 → dataconf-3.3.0}/dataconf/main.py +0 -0
- {dataconf-3.2.0 → dataconf-3.3.0}/dataconf/py.typed +0 -0
|
@@ -1,28 +1,24 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: dataconf
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.3.0
|
|
4
4
|
Summary: Simple dataclasses configuration management for Python with hocon/json/yaml/properties/env-vars/dict support.
|
|
5
5
|
Home-page: https://github.com/zifeo/dataconf
|
|
6
6
|
License: MPL-2.0
|
|
7
7
|
Keywords: configuration,dataclasses,yaml,hocon,json,properties,cli,environment variables
|
|
8
|
-
Requires-Python: >=3.
|
|
8
|
+
Requires-Python: >=3.9,<4.0
|
|
9
9
|
Classifier: License :: OSI Approved
|
|
10
10
|
Classifier: Programming Language :: Python
|
|
11
11
|
Classifier: Programming Language :: Python :: 3
|
|
12
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
13
12
|
Classifier: Programming Language :: Python :: 3.9
|
|
14
13
|
Classifier: Programming Language :: Python :: 3.10
|
|
15
14
|
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
-
Classifier: Programming Language :: Python :: 3.
|
|
17
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
19
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
16
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
21
|
-
Requires-Dist: PyYAML (>=6.0.
|
|
17
|
+
Requires-Dist: PyYAML (>=6.0.2,<7.0.0)
|
|
22
18
|
Requires-Dist: isodate (>=0.6.1,<0.7.0)
|
|
23
19
|
Requires-Dist: pyhocon (>=0.3.61,<0.4.0)
|
|
24
|
-
Requires-Dist: pyparsing (>=3.1.
|
|
25
|
-
Requires-Dist: python-dateutil (>=2.
|
|
20
|
+
Requires-Dist: pyparsing (>=3.1.4,<4.0.0)
|
|
21
|
+
Requires-Dist: python-dateutil (>=2.9.0.post0,<3.0.0)
|
|
26
22
|
Project-URL: Repository, https://github.com/zifeo/dataconf
|
|
27
23
|
Description-Content-Type: text/markdown
|
|
28
24
|
|
|
@@ -36,7 +32,7 @@ hocon/json/yaml/properties/env-vars/dict/cli support.
|
|
|
36
32
|
|
|
37
33
|
## Getting started
|
|
38
34
|
|
|
39
|
-
Requires at least Python 3.
|
|
35
|
+
Requires at least Python 3.9.
|
|
40
36
|
|
|
41
37
|
```bash
|
|
42
38
|
# pypi
|
|
@@ -105,11 +101,11 @@ zone {
|
|
|
105
101
|
|
|
106
102
|
class AbstractBaseClass:
|
|
107
103
|
pass
|
|
108
|
-
|
|
104
|
+
|
|
109
105
|
@dataclass
|
|
110
106
|
class Person(AbstractBaseClass):
|
|
111
107
|
name: Text
|
|
112
|
-
|
|
108
|
+
|
|
113
109
|
@dataclass
|
|
114
110
|
class Zone(AbstractBaseClass):
|
|
115
111
|
area_code: int
|
|
@@ -8,7 +8,7 @@ hocon/json/yaml/properties/env-vars/dict/cli support.
|
|
|
8
8
|
|
|
9
9
|
## Getting started
|
|
10
10
|
|
|
11
|
-
Requires at least Python 3.
|
|
11
|
+
Requires at least Python 3.9.
|
|
12
12
|
|
|
13
13
|
```bash
|
|
14
14
|
# pypi
|
|
@@ -77,11 +77,11 @@ zone {
|
|
|
77
77
|
|
|
78
78
|
class AbstractBaseClass:
|
|
79
79
|
pass
|
|
80
|
-
|
|
80
|
+
|
|
81
81
|
@dataclass
|
|
82
82
|
class Person(AbstractBaseClass):
|
|
83
83
|
name: Text
|
|
84
|
-
|
|
84
|
+
|
|
85
85
|
@dataclass
|
|
86
86
|
class Zone(AbstractBaseClass):
|
|
87
87
|
area_code: int
|
|
@@ -17,7 +17,7 @@ from typing import List
|
|
|
17
17
|
from typing import Type
|
|
18
18
|
from typing import Union
|
|
19
19
|
|
|
20
|
-
from dataconf.exceptions import AmbiguousSubclassException
|
|
20
|
+
from dataconf.exceptions import AmbiguousSubclassException, EnvListFormatException
|
|
21
21
|
from dataconf.exceptions import EnvListOrderException
|
|
22
22
|
from dataconf.exceptions import MalformedConfigException
|
|
23
23
|
from dataconf.exceptions import MissingTypeException
|
|
@@ -333,6 +333,8 @@ def __env_vars_parse(prefix: str, obj: Dict[str, Any]):
|
|
|
333
333
|
if len(p) == 1:
|
|
334
334
|
# []x
|
|
335
335
|
if isinstance(focus, list):
|
|
336
|
+
if not isinstance(p[0], int):
|
|
337
|
+
raise EnvListFormatException
|
|
336
338
|
if p[0] != len(focus):
|
|
337
339
|
raise EnvListOrderException
|
|
338
340
|
focus.append(v)
|
|
@@ -346,9 +348,8 @@ def __env_vars_parse(prefix: str, obj: Dict[str, Any]):
|
|
|
346
348
|
if p[0] not in focus:
|
|
347
349
|
# []{x}
|
|
348
350
|
if isinstance(focus, list):
|
|
349
|
-
if p[0]
|
|
350
|
-
|
|
351
|
-
focus.append({})
|
|
351
|
+
if p[0] == len(focus):
|
|
352
|
+
focus.append({})
|
|
352
353
|
# {}{x}
|
|
353
354
|
else:
|
|
354
355
|
focus[p[0]] = {}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "dataconf"
|
|
3
|
-
version = "3.
|
|
3
|
+
version = "3.3.0"
|
|
4
4
|
description = "Simple dataclasses configuration management for Python with hocon/json/yaml/properties/env-vars/dict support."
|
|
5
5
|
authors = []
|
|
6
6
|
license = "MPL-2.0"
|
|
@@ -12,10 +12,10 @@ include = [
|
|
|
12
12
|
classifiers = [
|
|
13
13
|
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
14
14
|
"Programming Language :: Python",
|
|
15
|
-
"Programming Language :: Python :: 3.8",
|
|
16
15
|
"Programming Language :: Python :: 3.9",
|
|
17
16
|
"Programming Language :: Python :: 3.10",
|
|
18
|
-
"Programming Language :: Python :: 3.11"
|
|
17
|
+
"Programming Language :: Python :: 3.11",
|
|
18
|
+
"Programming Language :: Python :: 3.12"
|
|
19
19
|
]
|
|
20
20
|
keywords = [
|
|
21
21
|
"configuration",
|
|
@@ -32,23 +32,23 @@ keywords = [
|
|
|
32
32
|
dataconf = 'dataconf.cli:run'
|
|
33
33
|
|
|
34
34
|
[tool.poetry.dependencies]
|
|
35
|
-
python = "^3.
|
|
36
|
-
python-dateutil = "^2.
|
|
37
|
-
PyYAML = "^6.0.
|
|
35
|
+
python = "^3.9"
|
|
36
|
+
python-dateutil = "^2.9.0.post0"
|
|
37
|
+
PyYAML = "^6.0.2"
|
|
38
38
|
isodate = "^0.6.1"
|
|
39
39
|
pyhocon = "^0.3.61"
|
|
40
|
-
pyparsing = "^3.1.
|
|
40
|
+
pyparsing = "^3.1.4"
|
|
41
41
|
|
|
42
42
|
[tool.poetry.group.dev.dependencies]
|
|
43
|
-
pytest = ">=
|
|
44
|
-
pre-commit = ">=
|
|
45
|
-
commitizen = ">=
|
|
46
|
-
pytest-httpserver = "^1.0
|
|
47
|
-
ruff = ">=0.
|
|
43
|
+
pytest = ">=8.3.3"
|
|
44
|
+
pre-commit = ">=3.8.0"
|
|
45
|
+
commitizen = ">=3.29.0"
|
|
46
|
+
pytest-httpserver = "^1.1.0"
|
|
47
|
+
ruff = ">=0.6.5"
|
|
48
48
|
|
|
49
49
|
[tool.commitizen]
|
|
50
50
|
name = "cz_conventional_commits"
|
|
51
|
-
version = "3.
|
|
51
|
+
version = "3.3.0"
|
|
52
52
|
tag_format = "v$major.$minor.$patch$prerelease"
|
|
53
53
|
version_files = [
|
|
54
54
|
"pyproject.toml:version",
|
dataconf-3.2.0/setup.py
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
from setuptools import setup
|
|
3
|
-
|
|
4
|
-
packages = \
|
|
5
|
-
['dataconf']
|
|
6
|
-
|
|
7
|
-
package_data = \
|
|
8
|
-
{'': ['*']}
|
|
9
|
-
|
|
10
|
-
install_requires = \
|
|
11
|
-
['PyYAML>=6.0.1,<7.0.0',
|
|
12
|
-
'isodate>=0.6.1,<0.7.0',
|
|
13
|
-
'pyhocon>=0.3.61,<0.4.0',
|
|
14
|
-
'pyparsing>=3.1.2,<4.0.0',
|
|
15
|
-
'python-dateutil>=2.8.2,<3.0.0']
|
|
16
|
-
|
|
17
|
-
entry_points = \
|
|
18
|
-
{'console_scripts': ['dataconf = dataconf.cli:run']}
|
|
19
|
-
|
|
20
|
-
setup_kwargs = {
|
|
21
|
-
'name': 'dataconf',
|
|
22
|
-
'version': '3.2.0',
|
|
23
|
-
'description': 'Simple dataclasses configuration management for Python with hocon/json/yaml/properties/env-vars/dict support.',
|
|
24
|
-
'long_description': '# Dataconf\n\n[](https://github.com/zifeo/dataconf/actions)\n[](https://badge.fury.io/py/dataconf)\n\nSimple dataclasses configuration management for Python with\nhocon/json/yaml/properties/env-vars/dict/cli support.\n\n## Getting started\n\nRequires at least Python 3.8.\n\n```bash\n# pypi\npip install dataconf\npoetry add dataconf\n\n# remote master\npip install --upgrade git+https://github.com/zifeo/dataconf.git\npoetry add git+https://github.com/zifeo/dataconf.git\n\n# local repo/dev\npoetry install\npre-commit install\n```\n\n## Usage\n\n```python\nimport os\nfrom dataclasses import dataclass, field\nfrom typing import List, Dict, Text, Union, Tuple\nfrom dateutil.relativedelta import relativedelta\nfrom datetime import datetime, timedelta\nimport dataconf\n\nconf = """\nstr_name = test\nstr_name = ${?HOME}\ndash-to-underscore = true\nfloat_num = 2.2\niso_datetime = "2000-01-01T20:00:00"\niso_duration = "P123DT4H5M6S"\nvariable_length_tuple_data = [\n 1\n 2\n 3\n]\ntuple_data = [\n a\n P1D\n]\n# this is a comment\nlist_data = [\n a\n b\n]\nnested {\n a = test\n b : 1\n}\nnested_list = [\n {\n a = test1\n b : 2.5\n }\n]\nduration = 2s\nunion = 1\npeople {\n name = Thailand\n}\nzone {\n area_code = 42\n}\n"""\n\nclass AbstractBaseClass:\n pass\n \n@dataclass\nclass Person(AbstractBaseClass):\n name: Text\n \n@dataclass\nclass Zone(AbstractBaseClass):\n area_code: int\n\n@dataclass\nclass Nested:\n a: Text\n b: float\n\n@dataclass\nclass Config:\n str_name: Text\n dash_to_underscore: bool\n float_num: float\n iso_datetime: datetime\n iso_duration: timedelta\n variable_length_tuple_data: Tuple[int, ...]\n tuple_data: Tuple[Text, timedelta]\n list_data: List[Text]\n nested: Nested\n nested_list: List[Nested]\n duration: relativedelta\n union: Union[Text, int]\n people: AbstractBaseClass\n zone: AbstractBaseClass\n default: Text = \'hello\'\n default_factory: Dict[Text, Text] = field(default_factory=dict)\n\nprint(dataconf.string(conf, Config))\n# Config(\n# str_name=\'/users/root/\',\n# dash_to_underscore=True,\n# float_num=2.2,\n# iso_datetime=datetime.datetime(2000, 1, 1, 20, 0),\n# iso_duration=datetime.timedelta(days=123, seconds=14706),\n# variable_length_tuple_data=(1,2,3),\n# tuple_data=(\'a\', datetime.timedelta(days=1)),\n# list_data=[\'a\', \'b\'],\n# nested=Nested(a=\'test\', b=1),\n# nested_list=[Nested(a=\'test1\', b=2.5)],\n# duration=relativedelta(seconds=+2),\n# union=1,\n# people=Person(name=\'Thailand\'),\n# zone=Zone(area_code=42),\n# default=\'hello\',\n# default_factory={}\n# )\n\n@dataclass\nclass Example:\n hello: str\n world: str\n foo: List[str]\n\nos.environ[\'DC_WORLD\'] = \'monde\'\n\nprint(\n dataconf\n .multi\n .url(\'https://raw.githubusercontent.com/zifeo/dataconf/main/confs/simple.hocon\')\n .env(\'DC\')\n .on(Example)\n)\n# Example(hello=\'bonjour\',world=\'monde\')\n```\n\n## API\n\n```python\nimport dataconf\n\nconf = dataconf.string(\'{ name: Test }\', Config)\nconf = dataconf.string(\'name:\\n\\tvalue: Test\', Config, loader=dataconf.YAML) # dataconf.HOCON by default\nconf = dataconf.env(\'PREFIX_\', Config)\nconf = dataconf.dict({\'name\': \'Test\'}, Config)\nconf = dataconf.url(\'https://raw.githubusercontent.com/zifeo/dataconf/master/confs/test.hocon\', Config) # hocon, json, yaml, properties\nconf = dataconf.file(\'confs/test.hocon\', Config) # hocon, json, yaml, properties\nconf = dataconf.cli(sys.argv, Config)\n\n# Aggregation\nconf = dataconf.multi.string(...).env(...).url(...).file(...).dict(...).cli(...).on(Config)\n\n# Same api as Python json/yaml packages (e.g. `load`, `loads`, `dump`, `dumps`)\nconf = dataconf.load(\'confs/test.hocon\', Config) # hocon, json, yaml, properties\nconf = dataconf.load(\'confs/test.yaml\', Config, loader=dataconf.YAML) # dataconf.HOCON by default\ndataconf.dump(\'confs/test.hocon\', conf, out=\'hocon\')\ndataconf.dump(\'confs/test.json\', conf, out=\'json\')\ndataconf.dump(\'confs/test.yaml\', conf, out=\'yaml\')\ndataconf.dump(\'confs/test.properties\', conf, out=\'properties\')\n```\n\nFor full HOCON capabilities see\n[here](https://github.com/chimpler/pyhocon/#example-of-hocon-file).\n\n## Parse env vars\n\n```bash\nPREFIX_VAR=a\nPREFIX_VAR_NAME=b\nPREFIX_TEST__NAME=c\nPREFIX_LS_0=d\nPREFIX_LS_1=e\nPREFIX_LSLS_0_0=f\nPREFIX_LSOB_0__NAME=g\nPREFIX_NESTED_="{ name: Test }"\nPREFIX_SUB_="{ value: ${PREFIX_VAR} }"\n```\n\nis equivalent to\n\n```\n{\n var = a\n var_name = b\n test {\n name = c\n }\n ls = [\n d\n e\n ]\n lsls = [\n [\n f\n ]\n ]\n lsob = [\n {\n name = g\n }\n ]\n nested {\n # parse nested config by suffixing env var with `_`\n name: Test\n }\n sub {\n # will have value "a" at parsing, useful for aliases\n value = ${PREFIX_VAR}\n }\n}\n```\n\nNote that when using `.env` source, the strict mode is disabled and value might\nbe casted.\n\n## Parse CLI arguments\n\nSame as env vars parse (dashes are converted to underscore, e.g. `TEST_A` →\n`--test-a`).\n\n## CLI usage\n\nCan be used for validation or converting between supported file formats (`-o`).\n\n```shell\ndataconf -c confs/test.hocon -m tests.configs -d TestConf -o hocon\n# dataconf.exceptions.TypeConfigException: expected type <class \'datetime.timedelta\'> at .duration, got <class \'int\'>\n```\n',
|
|
25
|
-
'author': 'None',
|
|
26
|
-
'author_email': 'None',
|
|
27
|
-
'maintainer': 'None',
|
|
28
|
-
'maintainer_email': 'None',
|
|
29
|
-
'url': 'https://github.com/zifeo/dataconf',
|
|
30
|
-
'packages': packages,
|
|
31
|
-
'package_data': package_data,
|
|
32
|
-
'install_requires': install_requires,
|
|
33
|
-
'entry_points': entry_points,
|
|
34
|
-
'python_requires': '>=3.8,<4.0',
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
setup(**setup_kwargs)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|