Coverage for rendercv/data/models/rendercv_data_model.py: 100%

19 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2024-10-07 17:51 +0000

1""" 

2The `rendercv.data.models.rendercv_data_model` module contains the `RenderCVDataModel` 

3data model, which is the main data model that defines the whole input file structure. 

4""" 

5 

6from typing import Optional 

7 

8import pydantic 

9 

10from ...themes import ClassicThemeOptions 

11from .base import RenderCVBaseModelWithoutExtraKeys 

12from .curriculum_vitae import CurriculumVitae 

13from .design import RenderCVDesign 

14from .locale_catalog import LocaleCatalog 

15from .rendercv_settings import RenderCVSettings 

16 

17 

18class RenderCVDataModel(RenderCVBaseModelWithoutExtraKeys): 

19 """This class binds both the CV and the design information together.""" 

20 

21 cv: CurriculumVitae = pydantic.Field( 

22 title="Curriculum Vitae", 

23 description="The data of the CV.", 

24 ) 

25 design: RenderCVDesign = pydantic.Field( 

26 default=ClassicThemeOptions(theme="classic"), 

27 title="Design", 

28 description=( 

29 "The design information of the CV. The default is the classic theme." 

30 ), 

31 ) 

32 locale_catalog: Optional[LocaleCatalog] = pydantic.Field( 

33 default=None, 

34 title="Locale Catalog", 

35 description=( 

36 "The locale catalog of the CV to allow the support of multiple languages." 

37 ), 

38 ) 

39 rendercv_settings: Optional[RenderCVSettings] = pydantic.Field( 

40 default=None, 

41 title="RenderCV Settings", 

42 description="The settings of the RenderCV.", 

43 ) 

44 

45 @pydantic.field_validator("locale_catalog") 

46 @classmethod 

47 def initialize_locale_catalog( 

48 cls, locale_catalog: Optional[LocaleCatalog] 

49 ) -> Optional[LocaleCatalog]: 

50 """Even if the locale catalog is not provided, initialize it with the default 

51 values.""" 

52 if locale_catalog is None: 

53 LocaleCatalog() 

54 

55 return locale_catalog