mirror of https://github.com/eyhc1/rendercv.git
improve data model
This commit is contained in:
parent
e17656b431
commit
7c5440a300
|
@ -0,0 +1,7 @@
|
||||||
|
from pydantic import BaseModel
|
||||||
|
from .content import CurriculumVitae
|
||||||
|
from .design import Design
|
||||||
|
|
||||||
|
class RenderCVDataModel(BaseModel):
|
||||||
|
design: Design
|
||||||
|
cv: CurriculumVitae
|
|
@ -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
|
|
@ -1,6 +1,6 @@
|
||||||
from jinja2 import Environment, FileSystemLoader
|
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 tinytex # https://github.com/praw-dev/praw/blob/master/praw/reddit.py
|
||||||
# from . import templates, sonra mesela: classic.render() tarzi seyler olabilir
|
# from . import templates, sonra mesela: classic.render() tarzi seyler olabilir
|
||||||
|
@ -30,9 +30,9 @@ if __name__ == "__main__":
|
||||||
with open(input_file_path) as file:
|
with open(input_file_path) as file:
|
||||||
raw_json = json.load(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:
|
# Create an output file and write the rendered LaTeX code to it:
|
||||||
output_file_path = os.path.join(workspace, "tests", "outputs", "test.tex")
|
output_file_path = os.path.join(workspace, "tests", "outputs", "test.tex")
|
||||||
|
|
Loading…
Reference in New Issue