configaroo 0.2.0__py3-none-any.whl → 0.2.1__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.
configaroo/__init__.py CHANGED
@@ -1,10 +1,17 @@
1
1
  """Bouncy configuration handling"""
2
2
 
3
- from configaroo.configuration import Configuration # noqa
4
- from configaroo.exceptions import ( # noqa
3
+ from configaroo.configuration import Configuration
4
+ from configaroo.exceptions import (
5
5
  ConfigarooException,
6
6
  MissingEnvironmentVariableError,
7
7
  UnsupportedLoaderError,
8
8
  )
9
9
 
10
- __version__ = "0.2.0"
10
+ __all__ = [
11
+ "Configuration",
12
+ "ConfigarooException",
13
+ "MissingEnvironmentVariableError",
14
+ "UnsupportedLoaderError",
15
+ ]
16
+
17
+ __version__ = "0.2.1"
@@ -108,18 +108,20 @@ class Configuration(UserDict):
108
108
  )
109
109
  return self
110
110
 
111
- def parse_dynamic(self, extra: dict[str, Any] | None = None) -> Self:
111
+ def parse_dynamic(
112
+ self, extra: dict[str, Any] | None = None, _include_self: bool = True
113
+ ) -> Self:
112
114
  """Parse dynamic values of the form {section.key}"""
113
115
  cls = type(self)
114
116
  variables = (
115
- self.to_flat_dict()
117
+ (self.to_flat_dict() if _include_self else {})
116
118
  | {"project_path": _find_pyproject_toml()}
117
119
  | ({} if extra is None else extra)
118
120
  )
119
- return cls(
121
+ parsed = cls(
120
122
  {
121
123
  key: (
122
- value.parse_dynamic(extra=variables)
124
+ value.parse_dynamic(extra=variables, _include_self=False)
123
125
  if isinstance(value, Configuration)
124
126
  else _incomplete_format(value, variables)
125
127
  if isinstance(value, str)
@@ -128,6 +130,10 @@ class Configuration(UserDict):
128
130
  for key, value in self.items()
129
131
  }
130
132
  )
133
+ if parsed == self:
134
+ return parsed
135
+ # Continue parsing until no more replacements are made.
136
+ return parsed.parse_dynamic(extra=extra, _include_self=_include_self)
131
137
 
132
138
  def validate_model(self, model: Type[BaseModel]) -> Self:
133
139
  """Validate the configuration against the given model."""
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: configaroo
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Summary: Bouncy handling of configuration files
5
5
  Author-email: Geir Arne Hjelle <geirarne@gmail.com>
6
6
  Maintainer-email: Geir Arne Hjelle <geirarne@gmail.com>
@@ -1,12 +1,12 @@
1
- configaroo/__init__.py,sha256=RNKHr1va5QmIdwDkkiGTnF8rR7EJMZZRfPunREdKjE4,255
2
- configaroo/configuration.py,sha256=lEpOBf3qwRFAM0T9Ur9Og1fYy65PzIY6xs1xSNsrHEM,7492
1
+ configaroo/__init__.py,sha256=-rsRqALc9-loy4qWJQHYE6QG0rZ1gwYjIUPy72DbsZg,371
2
+ configaroo/configuration.py,sha256=a39w6uHJMrc8pDbHZJX0dr8DVZ6gMFbFSLUlEPCMCdw,7779
3
3
  configaroo/exceptions.py,sha256=1h-6hV7VqqKaRFnu539pjsO0ESSNDibt2kUeF7jAM2M,374
4
4
  configaroo/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
5
  configaroo/loaders/__init__.py,sha256=-6GAR4g7vYW7Zagq9Ev479kpkfY7kbvDl4JPXd4wQQ0,756
6
6
  configaroo/loaders/json.py,sha256=6gs_ZegUEe70vb6uSJfKBos7UjfuJnyWgPE_kjDQISw,258
7
7
  configaroo/loaders/toml.py,sha256=ZVbHutZ7V-Z_jf2aHjV18jwaqCXumlr06j48rojHcBM,264
8
- configaroo-0.2.0.dist-info/licenses/LICENSE,sha256=2cbzsB4lU8qOO8fO1XVNJD7XPxzPhaWXm6U9DenSc0s,1089
9
- configaroo-0.2.0.dist-info/METADATA,sha256=JfEO1NNJw5qCXIB64Uf1fqdipAlnpkKCpLYpEbfJZGU,1789
10
- configaroo-0.2.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
11
- configaroo-0.2.0.dist-info/top_level.txt,sha256=JVYICl1cWSjvSOZuZMYm976z9lnZaWtHVRSt373QCxg,11
12
- configaroo-0.2.0.dist-info/RECORD,,
8
+ configaroo-0.2.1.dist-info/licenses/LICENSE,sha256=2cbzsB4lU8qOO8fO1XVNJD7XPxzPhaWXm6U9DenSc0s,1089
9
+ configaroo-0.2.1.dist-info/METADATA,sha256=0Od55T9MEvRBhi4JHllAU2S0U9NBl0T99yA2Axsf0wk,1789
10
+ configaroo-0.2.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
11
+ configaroo-0.2.1.dist-info/top_level.txt,sha256=JVYICl1cWSjvSOZuZMYm976z9lnZaWtHVRSt373QCxg,11
12
+ configaroo-0.2.1.dist-info/RECORD,,