From 7c5440a3001cd12f3548cae84888daaa936e2b30 Mon Sep 17 00:00:00 2001 From: Sina Atalay Date: Mon, 4 Sep 2023 19:31:11 +0200 Subject: [PATCH] improve data model --- rendercv/data/data_model.py | 7 +++++++ rendercv/data/design.py | 32 ++++++++++++++++++++++++++++++++ rendercv/rendercv.py | 6 +++--- 3 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 rendercv/data/data_model.py diff --git a/rendercv/data/data_model.py b/rendercv/data/data_model.py new file mode 100644 index 0000000..ad0e136 --- /dev/null +++ b/rendercv/data/data_model.py @@ -0,0 +1,7 @@ +from pydantic import BaseModel +from .content import CurriculumVitae +from .design import Design + +class RenderCVDataModel(BaseModel): + design: Design + cv: CurriculumVitae \ No newline at end of file diff --git a/rendercv/data/design.py b/rendercv/data/design.py index e69de29..4229b9b 100644 --- a/rendercv/data/design.py +++ b/rendercv/data/design.py @@ -0,0 +1,32 @@ +from pydantic import BaseModel, Field, HttpUrl, model_validator +from pydantic_extra_types.color import Color +from typing import Literal +from datetime import date as Date + +class ClassicTheme(BaseModel): + # 1) Mandotory user inputs: + # 2) Optional user inputs: + primary_color: Color = Field(default="blue") + + page_top_margin: str = Field(default="1.35cm") + page_bottom_margin: str = Field(default="1.35cm") + page_left_margin: str = Field(default="1.35cm") + page_right_margin: str = Field(default="1.35cm") + + section_title_top_margin: str = Field(default="0.13cm") + section_title_bottom_margin: str = Field(default="0.13cm") + + vertical_margin_between_sections: str = Field(default="0.13cm") + + vertical_margin_between_bullet_points: str = Field(default="0.07cm") + bullet_point_left_margin: str = Field(default="0.7cm") + + vertical_margin_between_entries: str = Field(default="0.12cm") + + vertical_margin_between_entries_and_highlights: str = Field(default="0.12cm") + + date_and_location_width: str = Field(default="3.7cm") + +class Design(BaseModel): + theme: Literal['classic'] = 'classic' + options: ClassicTheme \ No newline at end of file diff --git a/rendercv/rendercv.py b/rendercv/rendercv.py index d737ae1..8485252 100644 --- a/rendercv/rendercv.py +++ b/rendercv/rendercv.py @@ -1,6 +1,6 @@ from jinja2 import Environment, FileSystemLoader -from data.content import CurriculumVitae +from data.data_model import RenderCVDataModel # from . import tinytex # https://github.com/praw-dev/praw/blob/master/praw/reddit.py # from . import templates, sonra mesela: classic.render() tarzi seyler olabilir @@ -30,9 +30,9 @@ if __name__ == "__main__": with open(input_file_path) as file: raw_json = json.load(file) - cv = CurriculumVitae(**raw_json) + data = RenderCVDataModel(**raw_json) - output_latex_file = template.render(cv=cv) + output_latex_file = template.render(design=data.design.options, cv=data.cv) # Create an output file and write the rendered LaTeX code to it: output_file_path = os.path.join(workspace, "tests", "outputs", "test.tex")