cli: fix `create-theme` command based on sb2nov theme

This commit is contained in:
Sina Atalay 2024-04-30 20:00:51 +03:00
parent 3181c7c37e
commit 46c051aa41
1 changed files with 3 additions and 3 deletions

View File

@ -600,7 +600,7 @@ def cli_command_render(
try: try:
# set the key (for example, cv.sections.education.0.institution) to the # set the key (for example, cv.sections.education.0.institution) to the
# value # value
dm.set_or_update_a_value(data_model, key, value) data_model = dm.set_or_update_a_value(data_model, key, value)
except pydantic.ValidationError as e: except pydantic.ValidationError as e:
raise e raise e
except (ValueError, KeyError, IndexError, AttributeError): except (ValueError, KeyError, IndexError, AttributeError):
@ -797,13 +797,13 @@ def cli_command_create_theme(
based_on_theme_init_file_contents = based_on_theme_init_file.read_text() based_on_theme_init_file_contents = based_on_theme_init_file.read_text()
# generate the new init file: # generate the new init file:
class_name = f"{theme_name.title()}ThemeOptions" class_name = f"{theme_name.capitalize()}ThemeOptions"
literal_name = f'Literal["{theme_name}"]' literal_name = f'Literal["{theme_name}"]'
new_init_file_contents = ( new_init_file_contents = (
based_on_theme_init_file_contents.replace( based_on_theme_init_file_contents.replace(
f'Literal["{based_on}"]', literal_name f'Literal["{based_on}"]', literal_name
) )
.replace(f"{based_on.title()}ThemeOptions", class_name) .replace(f"{based_on.capitalize()}ThemeOptions", class_name)
.replace("..", "rendercv.themes") .replace("..", "rendercv.themes")
) )