Laden der Project.yaml aus dem Projekt-Verzeichnis
This commit is contained in:
+11
-1
@@ -2,6 +2,8 @@ from os import path
|
||||
from pathlib import Path
|
||||
from sys import platform
|
||||
from typing import Tuple, Type
|
||||
from pydantic_yaml import to_yaml_str, parse_yaml_file_as
|
||||
import polars as pl
|
||||
|
||||
from pydantic import BaseModel
|
||||
from pydantic_settings import BaseSettings, PydanticBaseSettingsSource, SettingsConfigDict, JsonConfigSettingsSource
|
||||
@@ -152,10 +154,18 @@ class TreeNode(BaseModel):
|
||||
|
||||
class PdfProjectSettings(BaseModel):
|
||||
"""
|
||||
Speichert Projekt-Einstellungen direkt im Ordner des Projekts in einer Klartextdatei JSON
|
||||
Speichert Projekt-Einstellungen direkt im Ordner des Projekts in einer Klartextdatei YAML
|
||||
"""
|
||||
|
||||
nodes: list[TreeNode] = []
|
||||
|
||||
@classmethod
|
||||
def readSettings(cls, project_dir: Path):
|
||||
return parse_yaml_file_as(PdfProjectSettings, project_dir / "project.yaml")
|
||||
|
||||
def writeSettings(self, project_dir: Path):
|
||||
with open(project_dir / "project.yaml", "w", encoding="utf8") as f:
|
||||
f.write(to_yaml_str(self))
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user