uEdition 0.7.0__py3-none-any.whl → 0.8.0__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.

Potentially problematic release.


This version of uEdition might be problematic. Click here for more details.

uedition/__about__.py CHANGED
@@ -2,4 +2,4 @@
2
2
  #
3
3
  # SPDX-License-Identifier: MIT
4
4
  """About this package."""
5
- __version__ = "0.7.0"
5
+ __version__ = "0.8.0"
uedition/cli/__init__.py CHANGED
@@ -60,13 +60,13 @@ def version() -> None:
60
60
  print_cli(f'Configuration: {settings["version"]}')
61
61
 
62
62
 
63
- @language_app.command()
63
+ @language_app.command("add")
64
64
  def language_add(path: str) -> None:
65
65
  """Add a language to the μEdition."""
66
66
  language_module.add(path)
67
67
 
68
68
 
69
- @language_app.command()
69
+ @language_app.command("update")
70
70
  def language_update(path: str) -> None:
71
71
  """Update a language."""
72
72
  language_module.update(path)
uedition/settings.py CHANGED
@@ -7,10 +7,59 @@ All application settings are accessed via the `settings` dictionary.
7
7
  """
8
8
  import os
9
9
 
10
- from pydantic import BaseSettings, BaseModel
11
- from pydantic.env_settings import SettingsSourceCallable
10
+ from pydantic import BaseModel
11
+ from pydantic.fields import FieldInfo
12
+ from pydantic_settings import BaseSettings, PydanticBaseSettingsSource
12
13
  from yaml import safe_load
13
- from typing import Any
14
+ from typing import Any, Type, Tuple, Dict
15
+
16
+
17
+ class YAMLConfigSettingsSource(PydanticBaseSettingsSource):
18
+ """Loads the configuration settings from a YAML file."""
19
+
20
+ def get_field_value(
21
+ self: "YAMLConfigSettingsSource", field: FieldInfo, field_name: str
22
+ ) -> Tuple[Any, str, bool]:
23
+ """Get the value of a specific field."""
24
+ encoding = self.config.get("env_file_encoding")
25
+ file_content_json = None
26
+ if os.path.exists("uEdition.yaml"):
27
+ with open("uEdition.yaml", encoding=encoding) as in_f:
28
+ file_content_json = safe_load(in_f)
29
+ elif os.path.exists("uEdition.yml"):
30
+ with open("uEdition.yml", encoding=encoding) as in_f:
31
+ file_content_json = safe_load(in_f)
32
+ if file_content_json is not None:
33
+ field_value = file_content_json.get(field_name)
34
+ else:
35
+ field_value = None
36
+ return field_value, field_name, False
37
+
38
+ def prepare_field_value(
39
+ self: "YAMLConfigSettingsSource",
40
+ field_name: str,
41
+ field: FieldInfo,
42
+ value: Any,
43
+ value_is_complex: bool,
44
+ ) -> Any:
45
+ """Just return the value."""
46
+ return value
47
+
48
+ def __call__(self: "YAMLConfigSettingsSource") -> Dict[str, Any]:
49
+ """Call the loader."""
50
+ d: Dict[str, Any] = {}
51
+
52
+ for field_name, field in self.settings_cls.model_fields.items():
53
+ field_value, field_key, value_is_complex = self.get_field_value(
54
+ field, field_name
55
+ )
56
+ field_value = self.prepare_field_value(
57
+ field_name, field, field_value, value_is_complex
58
+ )
59
+ if field_value is not None:
60
+ d[field_key] = field_value
61
+
62
+ return d
14
63
 
15
64
 
16
65
  def uedition_yaml_settings(settings: BaseSettings) -> dict[str, Any]:
@@ -75,26 +124,25 @@ class Settings(BaseSettings):
75
124
  jb_config: dict = {}
76
125
  """Additional JupyterBook configuration."""
77
126
 
78
- class Config:
79
- """Configuration overrides."""
80
-
81
- @classmethod
82
- def customise_sources(
83
- cls, # noqa: ANN102
84
- init_settings: SettingsSourceCallable,
85
- env_settings: SettingsSourceCallable,
86
- file_secret_settings: SettingsSourceCallable,
87
- ) -> tuple[SettingsSourceCallable, ...]:
88
- """Add the YAMl loading functionality."""
89
- return (
90
- env_settings,
91
- init_settings,
92
- file_secret_settings,
93
- uedition_yaml_settings,
94
- )
95
-
96
-
97
- settings = Settings().dict()
127
+ @classmethod
128
+ def settings_customise_sources(
129
+ cls: Type["Settings"],
130
+ settings_cls: Type[BaseSettings],
131
+ init_settings: PydanticBaseSettingsSource,
132
+ env_settings: PydanticBaseSettingsSource,
133
+ dotenv_settings: PydanticBaseSettingsSource,
134
+ file_secret_settings: PydanticBaseSettingsSource,
135
+ ) -> Tuple[PydanticBaseSettingsSource, ...]:
136
+ """Customise the settings sources."""
137
+ return (
138
+ init_settings,
139
+ env_settings,
140
+ file_secret_settings,
141
+ YAMLConfigSettingsSource(settings_cls),
142
+ )
143
+
144
+
145
+ settings = Settings().model_dump()
98
146
 
99
147
 
100
148
  def reload_settings() -> None:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: uEdition
3
- Version: 0.7.0
3
+ Version: 0.8.0
4
4
  Project-URL: Documentation, https://github.com/unknown/uedition#readme
5
5
  Project-URL: Issues, https://github.com/unknown/uedition/issues
6
6
  Project-URL: Source, https://github.com/unknown/uedition
@@ -14,11 +14,12 @@ Classifier: Programming Language :: Python :: 3.11
14
14
  Classifier: Programming Language :: Python :: Implementation :: CPython
15
15
  Classifier: Programming Language :: Python :: Implementation :: PyPy
16
16
  Requires-Python: >=3.10
17
- Requires-Dist: copier<9.0.0,>=8.0.0
17
+ Requires-Dist: copier<10.0.0,>=9.0.0
18
18
  Requires-Dist: jupyter-book<1.0.0,>=0.15.1
19
19
  Requires-Dist: livereload
20
- Requires-Dist: lxml<5.0.0,>=4.9.2
21
- Requires-Dist: pydantic[dotenv]<2.0.0,>=1.0.0
20
+ Requires-Dist: lxml<6.0.0,>=4.9.2
21
+ Requires-Dist: pydantic-settings<3.0.0,>=2.0.0
22
+ Requires-Dist: pydantic<3.0.0,>=2.0.0
22
23
  Requires-Dist: pyyaml<7.0.0,>=6.0.0
23
24
  Requires-Dist: typer[all]<1.0.0
24
25
  Description-Content-Type: text/markdown
@@ -1,8 +1,8 @@
1
- uedition/__about__.py,sha256=7Oa7k1v3RP9FXnafNXCwzLGxcVR2wiaboRUCMX8AXpA,157
1
+ uedition/__about__.py,sha256=ZKY67hSUtUpZScVZxX9OP2T8_jgQEouuMOKpfXwtpjY,157
2
2
  uedition/__init__.py,sha256=IfQLccTve4Bc-f7TpeuOwXWE03DFAJoWpveFacMiBSA,285
3
3
  uedition/__main__.py,sha256=FpsS6LdCNPdC5twonoqvfrqWDyCNreKQz7t9ZeSHcLI,182
4
- uedition/settings.py,sha256=5Bb1GxJeePFaQVPTzZP0vfwJ09zgdv0OrvoJ7HbAL7g,2900
5
- uedition/cli/__init__.py,sha256=DmLuxuth3_GwofY4xJl50s0rB0NqTC34-KhIB9IKjVA,1515
4
+ uedition/settings.py,sha256=n1L-c-gkvlowGSMuuH5UT_B2WBUMckQgy5Uu2md56fY,4708
5
+ uedition/cli/__init__.py,sha256=5-kozUHJCDa0-ii9fPq6GtZQCC2sQG1L5WiRHuPiKNg,1528
6
6
  uedition/cli/build.py,sha256=Z9yQ2-FxcEGtoOPvWBiJpaCPJArKuScJEXdVr1Nw3pE,6204
7
7
  uedition/cli/check.py,sha256=OE5Mis1PwCwqnVBk1waR4AyOVeGBzI5Rudp653hMKAw,7352
8
8
  uedition/cli/create.py,sha256=Q-SvDq9VtmUP4DQhuuvt1eZ_72sX8_tcFOj2Bt_T6J8,371
@@ -15,8 +15,8 @@ uedition/ext/language_switcher.css,sha256=y4LzkCgCm6E_nHt15I4Ku5QzBNpjwda9bt9Fsq
15
15
  uedition/ext/language_switcher.js,sha256=5CL1Es5T_s0qXcbYtpycvh0tMNdn97MHWCoGECe5w0w,2661
16
16
  uedition/ext/language_switcher.py,sha256=2kWXKyVyPCUFIdO24azyNg03GYrJwasJ84wNpM1eFFY,1369
17
17
  uedition/ext/tei.py,sha256=VOVbecTA7b4HiJuh-ZAc9ZJd0DsJUmwUO-JO_wvByDk,11380
18
- uedition-0.7.0.dist-info/METADATA,sha256=l5o1g3124J7-DhhWF0zgGk5t8Hil4XSVyJxgsA5xHAA,1974
19
- uedition-0.7.0.dist-info/WHEEL,sha256=9QBuHhg6FNW7lppboF2vKVbCGTVzsFykgRQjjlajrhA,87
20
- uedition-0.7.0.dist-info/entry_points.txt,sha256=Mor9i2VYxcNQcLbMmWGpFYSwsMs3MyewnLmFI3IG0Ls,46
21
- uedition-0.7.0.dist-info/licenses/LICENSE.txt,sha256=MhLJl8GE8mnuO5i_pvKaobpIGnhiAEdkY-a6LKiuwCE,1101
22
- uedition-0.7.0.dist-info/RECORD,,
18
+ uedition-0.8.0.dist-info/METADATA,sha256=RE11bhXsEdpEWmrGo6c1g5mOk8iN4nowGQJJIT7ynfg,2014
19
+ uedition-0.8.0.dist-info/WHEEL,sha256=mRYSEL3Ih6g5a_CVMIcwiF__0Ae4_gLYh01YFNwiq1k,87
20
+ uedition-0.8.0.dist-info/entry_points.txt,sha256=Mor9i2VYxcNQcLbMmWGpFYSwsMs3MyewnLmFI3IG0Ls,46
21
+ uedition-0.8.0.dist-info/licenses/LICENSE.txt,sha256=MhLJl8GE8mnuO5i_pvKaobpIGnhiAEdkY-a6LKiuwCE,1101
22
+ uedition-0.8.0.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: hatchling 1.18.0
2
+ Generator: hatchling 1.21.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any