rendercv.cli.utilities
¶
The rendercv.cli.utilities
module contains utility functions that are required by CLI.
set_or_update_a_value(dictionary, key, value, sub_dictionary=None)
¶
Set or update a value in a dictionary for the given key. For example, a key can
be cv.sections.education.3.institution
and the value can be "Bogazici University".
Parameters:
-
dictionary
(dict
) –The dictionary to set or update the value.
-
key
(str
) –The key to set or update the value.
-
value
(str
) –The value to set or update.
-
sub_dictionary
(Optional[dict | list]
, default:None
) –The sub dictionary to set or update the value. This is used for recursive calls. Defaults to None.
Source code in rendercv/cli/utilities.py
set_or_update_values(dictionary, key_and_values)
¶
Set or update values in a dictionary for the given keys. It uses the
set_or_update_a_value
function to set or update the values.
Parameters:
-
dictionary
(dict
) –The dictionary to set or update the values.
-
key_and_values
(dict[str, str]
) –The key and value pairs to set or update.
Source code in rendercv/cli/utilities.py
copy_files(paths, new_path)
¶
Copy files to the given path. If there are multiple files, then rename the new path by adding a number to the end of the path.
Parameters:
-
paths
(list[Path] | Path
) –The paths of the files to be copied.
-
new_path
(Path
) –The path to copy the files to.
Source code in rendercv/cli/utilities.py
get_latest_version_number_from_pypi()
¶
Get the latest version number of RenderCV from PyPI.
Returns:
-
Optional[str]
–The latest version number of RenderCV from PyPI. Returns None if the version
-
Optional[str]
–number cannot be fetched.
Source code in rendercv/cli/utilities.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/cli/utilities.py
copy_templates(folder_name, copy_to, new_folder_name=None)
¶
Copy one of the folders found in rendercv.templates
to copy_to
.
Parameters:
-
folder_name
(str
) –The name of the folder to be copied.
-
copy_to
(Path
) –The path to copy the folder to.
Returns:
-
Optional[Path]
–The path to the copied folder.
Source code in rendercv/cli/utilities.py
parse_render_command_override_arguments(extra_arguments)
¶
Parse extra arguments given to the render
command as data model key and value
pairs and return them as a dictionary.
Parameters:
-
extra_arguments
(Context
) –The extra arguments context.
Returns:
-
dict[str, str]
–The key and value pairs.
Source code in rendercv/cli/utilities.py
get_default_render_command_cli_arguments()
¶
Get the default values of the render
command's CLI arguments.
Returns:
-
dict
–The default values of the
render
command's CLI arguments.
Source code in rendercv/cli/utilities.py
update_render_command_settings_of_the_input_file(input_file_as_a_dict, render_command_cli_arguments)
¶
Update the input file's rendercv_settings.render_command
field with the given
values (only the non-default ones) of the render
command's CLI arguments.
Parameters:
-
input_file_as_a_dict
(dict
) –The input file as a dictionary.
-
render_command_cli_arguments
(dict
) –The command line arguments of the
render
command.
Returns:
-
dict
–The updated input file as a dictionary.
Source code in rendercv/cli/utilities.py
run_rendercv_with_printer(input_file_as_a_dict, working_directory, input_file_path)
¶
Run RenderCV with a live progress reporter. Working dictionary is where the output files will be saved. Input file path is required for accessing the template overrides.
Parameters:
-
input_file_as_a_dict
(dict
) –The input file as a dictionary.
-
working_directory
(Path
) –The working directory where the output files will be saved.
-
input_file_path
(Path
) –The path of the input file.
Source code in rendercv/cli/utilities.py
310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 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 |
|
run_a_function_if_a_file_changes(file_path, function)
¶
Watch the file located at file_path
and call the function
when the file is
modified. The function should not take any arguments.
Parameters:
-
file_path
(Path
) –The path of the file to watch for.
-
function
(Callable
) –The function to be called on file modification.
Source code in rendercv/cli/utilities.py
read_and_construct_the_input(input_file_path, cli_render_arguments, extra_data_model_override_arguments=None)
¶
Read RenderCV YAML files and CLI to construct the user's input as a dictionary. Input file is read, CLI arguments override the input file, and individual design, locale catalog, etc. files are read if they are provided.
Parameters:
-
input_file_path
(Path
) –The path of the input file.
-
cli_render_arguments
(dict[str, Any]
) –The command line arguments of the
render
command. -
extra_data_model_override_arguments
(Optional[Context]
, default:None
) –The extra arguments context. Defaults to None.
Returns:
-
dict
–The input of the user as a dictionary.