rendercv.data
¶
The rendercv.data
package contains the necessary classes and functions for
- Parsing and validating a YAML input file
- Computing some properties based on a YAML input file (like converting ISO dates to plain English, URLs of social networks, etc.)
- Generating a JSON Schema for RenderCV's data format
- Generating a sample YAML input file
The validators and data format of RenderCV are written using Pydantic.
BulletEntry
¶
Bases: RenderCVBaseModelWithExtraKeys
This class is the data model of BulletEntry
.
Source code in rendercv/data/models/entry_types.py
make_keywords_bold(keywords)
¶
Make the given keywords bold in the bullet
field.
Parameters:
-
keywords
(list[str]
) –The keywords to make bold.
Returns:
-
BulletEntry
–A BulletEntry with the keywords made bold in the
bullet
field.
Source code in rendercv/data/models/entry_types.py
CurriculumVitae
¶
Bases: RenderCVBaseModelWithExtraKeys
This class is the data model of the cv
field.
Source code in rendercv/data/models/curriculum_vitae.py
380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 |
|
connections: list[dict[str, Optional[str]]]
cached
property
¶
Return all the connections of the person as a list of dictionaries and cache
connections
as an attribute of the instance. The connections are used in the
header of the CV.
Returns:
-
list[dict[str, Optional[str]]]
–The connections of the person.
sections: list[SectionBase]
cached
property
¶
Compute the sections of the CV based on the input sections.
The original sections
input is a dictionary where the keys are the section titles
and the values are the list of entries in that section. This function converts the
input sections to a list of SectionBase
objects. This makes it easier to work with
the sections in the rest of the code.
Returns:
-
list[SectionBase]
–The computed sections.
update_photo_path(value)
classmethod
¶
Cast photo
to Path and make the path absolute
Source code in rendercv/data/models/curriculum_vitae.py
update_curriculum_vitae(value, info)
classmethod
¶
Update the curriculum_vitae
dictionary.
Source code in rendercv/data/models/curriculum_vitae.py
EducationEntry
¶
Bases: EntryBase
, EducationEntryBase
This class is the data model of EducationEntry
. EducationEntry
class is
created by combining the EntryBase
and EducationEntryBase
classes to have the
fields in the correct order.
Source code in rendercv/data/models/entry_types.py
ExperienceEntry
¶
Bases: EntryBase
, ExperienceEntryBase
This class is the data model of ExperienceEntry
. ExperienceEntry
class is
created by combining the EntryBase
and ExperienceEntryBase
classes to have the
fields in the correct order.
Source code in rendercv/data/models/entry_types.py
Locale
¶
Bases: RenderCVBaseModelWithoutExtraKeys
This class is the data model of the locale catalog. The values of each field
updates the locale
dictionary.
Source code in rendercv/data/models/locale.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
|
update_locale(value, info)
classmethod
¶
Update the locale
dictionary.
Source code in rendercv/data/models/locale.py
NormalEntry
¶
Bases: EntryBase
, NormalEntryBase
This class is the data model of NormalEntry
. NormalEntry
class is created by
combining the EntryBase
and NormalEntryBase
classes to have the fields in the
correct order.
Source code in rendercv/data/models/entry_types.py
OneLineEntry
¶
Bases: RenderCVBaseModelWithExtraKeys
This class is the data model of OneLineEntry
.
Source code in rendercv/data/models/entry_types.py
make_keywords_bold(keywords)
¶
Make the given keywords bold in the details
field.
Parameters:
-
keywords
(list[str]
) –The keywords to make bold.
Returns:
-
OneLineEntry
–A OneLineEntry with the keywords made bold in the
details
field.
Source code in rendercv/data/models/entry_types.py
PublicationEntry
¶
Bases: EntryWithDate
, PublicationEntryBase
This class is the data model of PublicationEntry
. PublicationEntry
class is
created by combining the EntryWithDate
and PublicationEntryBase
classes to have
the fields in the correct order.
Source code in rendercv/data/models/entry_types.py
RenderCommandSettings
¶
Bases: RenderCVBaseModelWithoutExtraKeys
This class is the data model of the render
command's settings.
Source code in rendercv/data/models/rendercv_settings.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
|
replace_placeholders(value)
classmethod
¶
Replaces the placeholders in a string with the corresponding values.
Source code in rendercv/data/models/rendercv_settings.py
convert_string_to_path(value)
classmethod
¶
Converts a string to a pathlib.Path
object by replacing the placeholders
with the corresponding values. If the path is not an absolute path, it is
converted to an absolute path by prepending the current working directory.
Source code in rendercv/data/models/rendercv_settings.py
RenderCVDataModel
¶
Bases: RenderCVBaseModelWithoutExtraKeys
This class binds both the CV and the design information together.
Source code in rendercv/data/models/rendercv_data_model.py
update_paths(model, info)
classmethod
¶
Update the paths in the RenderCV settings.
Source code in rendercv/data/models/rendercv_data_model.py
update_locale(value)
classmethod
¶
Update the output folder name in the RenderCV settings.
Source code in rendercv/data/models/rendercv_data_model.py
RenderCVSettings
¶
Bases: RenderCVBaseModelWithoutExtraKeys
This class is the data model of the RenderCV settings.
Source code in rendercv/data/models/rendercv_settings.py
mock_today(value)
classmethod
¶
Mocks the current date for testing.
Source code in rendercv/data/models/rendercv_settings.py
SocialNetwork
¶
Bases: RenderCVBaseModelWithoutExtraKeys
This class is the data model of a social network.
Source code in rendercv/data/models/curriculum_vitae.py
url: str
cached
property
¶
Return the URL of the social network and cache url
as an attribute of the
instance.
check_username(username, info)
classmethod
¶
Check if the username is provided correctly.
Source code in rendercv/data/models/curriculum_vitae.py
check_url()
¶
Validate the URL of the social network.
Source code in rendercv/data/models/curriculum_vitae.py
create_a_sample_data_model(name='John Doe', theme='classic')
¶
Return a sample data model for new users to start with.
Parameters:
-
name
(str
, default:'John Doe'
) –The name of the person. Defaults to "John Doe".
Returns:
-
RenderCVDataModel
–A sample data model.
Source code in rendercv/data/generator.py
create_a_sample_yaml_input_file(input_file_path=None, name='John Doe', theme='classic')
¶
Create a sample YAML input file and return it as a string. If the input file path is provided, then also save the contents to the file.
Parameters:
-
input_file_path
(Optional[Path]
, default:None
) –The path to save the input file. Defaults to None.
-
name
(str
, default:'John Doe'
) –The name of the person. Defaults to "John Doe".
-
theme
(str
, default:'classic'
) –The theme of the CV. Defaults to "classic".
Returns:
-
str
–The sample YAML input file as a string.
Source code in rendercv/data/generator.py
generate_json_schema()
¶
Generate the JSON schema of RenderCV.
JSON schema is generated for the users to make it easier for them to write the input file. The JSON Schema of RenderCV is saved in the root directory of the repository and distributed to the users with the JSON Schema Store.
Returns:
-
dict
–The JSON schema of RenderCV.
Source code in rendercv/data/generator.py
generate_json_schema_file(json_schema_path)
¶
Generate the JSON schema of RenderCV and save it to a file.
Parameters:
-
json_schema_path
(Path
) –The path to save the JSON schema.
Source code in rendercv/data/generator.py
format_date(date, date_template=None)
¶
Formats a Date
object to a string in the following format: "Jan 2021". The
month names are taken from the locale
dictionary from the
rendercv.data_models.models
module.
Parameters:
-
date
(date
) –The date to format.
-
date_template
(Optional[str]
, default:None
) –The template of the date string. If not provided, the default date style from the
locale
dictionary will be used.
Returns:
-
str
–The formatted date.
Source code in rendercv/data/models/computers.py
get_date_input()
¶
make_a_url_clean(url)
¶
Make a URL clean by removing the protocol, www, and trailing slashes.
Parameters:
-
url
(str
) –The URL to make clean.
Returns:
-
str
–The clean URL.
Source code in rendercv/data/models/computers.py
make_keywords_bold_in_a_string(string, keywords)
¶
Make the given keywords bold in the given string.
Source code in rendercv/data/models/entry_types.py
get_error_message_and_location_and_value_from_a_custom_error(error_string)
¶
Look at a string and figure out if it's a custom error message that has been
sent from rendercv.data.reader.read_input_file
. If it is, then return the custom
message, location, and the input value.
This is done because sometimes we raise an error about a specific field in the model validation level, but Pydantic doesn't give us the exact location of the error because it's a model-level error. So, we raise a custom error with three string arguments: message, location, and input value. Those arguments then combined into a string by Python. This function is used to parse that custom error message and return the three values.
Parameters:
-
error_string
(str
) –The error message.
Returns:
-
tuple[Optional[str], Optional[str], Optional[str]]
–The custom message, location, and the input value.
Source code in rendercv/data/reader.py
parse_validation_errors(exception)
¶
Take a Pydantic validation error, parse it, and return a list of error dictionaries that contain the error messages, locations, and the input values.
Pydantic's ValidationError
object is a complex object that contains a lot of
information about the error. This function takes a ValidationError
object and
extracts the error messages, locations, and the input values.
Parameters:
-
exception
(ValidationError
) –The Pydantic validation error object.
Returns:
-
list[dict[str, str]]
–A list of error dictionaries that contain the error messages, locations, and the
-
list[dict[str, str]]
–input values.
Source code in rendercv/data/reader.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 |
|
read_a_yaml_file(file_path_or_contents)
¶
Read a YAML file and return its content as a dictionary. The YAML file can be given as a path to the file or as the contents of the file as a string.
Parameters:
-
file_path_or_contents
(Path | str
) –The path to the YAML file or the contents of the YAML file as a string.
Returns:
-
dict
–The content of the YAML file as a dictionary.
Source code in rendercv/data/reader.py
read_input_file(file_path_or_contents)
¶
Read the input file (YAML or JSON) and return them as an instance of
RenderCVDataModel
, which is a Pydantic data model of RenderCV's data format.
Parameters:
-
file_path_or_contents
(Path | str
) –The path to the input file or the contents of the input file as a string.
Returns:
-
RenderCVDataModel
–The data model.
Source code in rendercv/data/reader.py
validate_input_dictionary_and_return_the_data_model(input_dictionary, context=None)
¶
Validate the input dictionary by creating an instance of RenderCVDataModel
,
which is a Pydantic data model of RenderCV's data format.
Parameters:
-
input_dictionary
(dict
) –The input dictionary.
-
context
(Optional[dict]
, default:None
) –The context dictionary that is used to validate the input dictionary. It's used to send the input file path with the context object, but it's not required.
Returns:
-
RenderCVDataModel
–The data model.