From 53bc1c4ee25429d5b0c1633ef2ec62c8aa3a2d5d Mon Sep 17 00:00:00 2001 From: Sina Atalay Date: Sun, 28 Apr 2024 19:21:20 +0300 Subject: [PATCH] data_models: refactor --- rendercv/data_models.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/rendercv/data_models.py b/rendercv/data_models.py index ec9119f..f0867d4 100644 --- a/rendercv/data_models.py +++ b/rendercv/data_models.py @@ -1187,6 +1187,13 @@ def get_a_sample_data_model( Returns: RenderCVDataModel: A sample data model. """ + # check if the theme is valid: + if theme not in available_themes: + raise ValueError( + f"The theme should be one of the following: {", ".join(available_themes)}!" + f" The provided theme is \"{theme}\"." + ) + name = name.encode().decode("unicode-escape") sections = { "summary": [ @@ -1394,12 +1401,6 @@ def get_a_sample_data_model( sections=sections, # type: ignore ) - if theme not in available_themes: - raise ValueError( - f"The theme should be one of the following: {available_themes}! The" - f" provided theme is {theme}." - ) - if theme == "classic": design = ClassicThemeOptions(theme="classic", show_timespan_in=["Experience"]) else: