Coverage for src / rendercv / schema / models / cv / entries / bases / entry.py: 100%
10 statements
« prev ^ index » next coverage.py v7.13.4, created at 2026-03-25 13:49 +0000
« prev ^ index » next coverage.py v7.13.4, created at 2026-03-25 13:49 +0000
1import functools
2import re
4import pydantic
6from ....base import BaseModelWithExtraKeys
8entry_type_to_snake_case_pattern = re.compile(r"(?<!^)(?=[A-Z])")
11class BaseEntry(BaseModelWithExtraKeys):
12 """Base class for all CV entry types.
14 Why:
15 All entry types share common configuration (extra keys allowed for
16 template fields, JSON schema description suppressed). This base
17 provides the shared config and entry type introspection.
18 """
20 model_config = pydantic.ConfigDict(json_schema_extra={"description": None})
22 @functools.cached_property
23 def entry_type_in_snake_case(self) -> str:
24 """Convert class name to snake_case for template attribute lookup.
26 Why:
27 Template collections store entry templates keyed by snake_case
28 entry type names (e.g., ``education_entry``). This property
29 enables dynamic lookup from the class name.
31 Returns:
32 Snake_case version of the entry class name.
33 """
34 return entry_type_to_snake_case_pattern.sub(
35 "_", self.__class__.__name__
36 ).lower()