diff --git a/pyproject.toml b/pyproject.toml index fae4d4c..ff2cb07 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -66,7 +66,7 @@ description = 'A LaTeX CV/resume framework' authors = [{ name = 'Sina Atalay', email = 'dev@atalay.biz' }] license = "MIT" readme = "README.md" -requires-python = '>=3.10' +# requires-python = '>=3.10' # RenderCV depends on these packages. They will be installed automatically when RenderCV # is installed: dependencies = [ diff --git a/rendercv/data_models.py b/rendercv/data_models.py index 0164544..a437cdb 100644 --- a/rendercv/data_models.py +++ b/rendercv/data_models.py @@ -34,9 +34,8 @@ from .themes.classic import ClassicThemeOptions from .themes.engineeringresumes import EngineeringresumesThemeOptions from .themes.moderncv import ModerncvThemeOptions from .themes.sb2nov import Sb2novThemeOptions +from .themes import ThemeOptions -# Disable Pydantic warnings: -warnings.filterwarnings("ignore") # The dictionary below will be overwritten by LocaleCatalog class. @@ -115,7 +114,7 @@ class RenderCVBaseModel(pydantic.BaseModel): unknown key is provided in the input file. """ - model_config = pydantic.ConfigDict(extra="forbid") + model_config = pydantic.ConfigDict(extra="allow") # ====================================================================================== @@ -792,6 +791,7 @@ def validate_section_input( "entries": sections_input, } + # Parse the section: try: section_type.model_validate( test_section, @@ -1236,6 +1236,15 @@ class RenderCVDataModel(RenderCVBaseModel): # Convert the arguments to a tuple theme_data_model_types_tuple = tuple(theme_data_model_types.__args__) if hasattr(theme_data_model_types, '__args__') else (theme_data_model_types,) + # Due to how the original code is written, we need to check the custom theme is not in any other folder than the working directory. + parent_folder = pathlib.Path(design["theme"]).parent + if parent_folder.name: + raise ValueError( + f"The custom theme folder should be in the working directory as the input file. Please move the custom theme folder from {parent_folder.absolute()} to the working directory {pathlib.Path.cwd()}.", + "theme", + design["theme"], + ) + if isinstance(design, theme_data_model_types_tuple): # Then it means RenderCVDataModel is already initialized with a design, so # return it as is: @@ -1323,7 +1332,11 @@ class RenderCVDataModel(RenderCVBaseModel): else: # Then it means there is no __init__.py file in the custom theme folder. # Create a dummy data model and use that instead. - class ThemeOptionsAreNotProvided(RenderCVBaseModel): + warnings.warn( + f"The custom theme {theme_name} doesn't have an __init__.py file." + " RenderCV will use a dummy data model for the theme options." + ) + class ThemeOptionsAreNotProvided(ThemeOptions): theme: str = theme_name theme_data_model = ThemeOptionsAreNotProvided(theme=theme_name) diff --git a/rendercv/renderer.py b/rendercv/renderer.py index 75b5b55..92f47d3 100644 --- a/rendercv/renderer.py +++ b/rendercv/renderer.py @@ -1029,26 +1029,29 @@ def latex_to_pdf( ) as latex_process: output = latex_process.communicate() # wait for the process to finish if latex_process.returncode != 0: - raise RuntimeError( - "Unfortunately, RenderCV's built-in TinyTeX binaries couldn't render" - " this LaTeX file into a PDF. This could be caused by one of two" - " reasons:\n\n1- The theme templates might have been updated in a way" - " RenderCV's TinyTeX cannot render. RenderCV's TinyTeX is minified to" - " keep the package size small. As a result, it doesn't function like a" - " general-purpose LaTeX distribution.\n2- Special characters, like" - " Greek or Chinese letters, that are not compatible with the fonts used" - " or RenderCV's TinyTeX might have been used.\n\nHowever, this issue" - " can be resolved quickly. RenderCV allows you to run your own LaTeX" - " distribution instead of the built-in TinyTeX. This can be done with" - " the '--use-local-latex-command' option, as shown below:\n\nrendercv" - " render --use-local-latex-command lualatex John_Doe_CV.yaml\n\nIf you" - " ensure that the generated LaTeX file can be compiled by your local" - " LaTeX distribution, RenderCV will work successfully. You can debug" - " the generated LaTeX file in your LaTeX editor to resolve any bugs." - " Then, you can start using RenderCV with your local LaTeX" - " distribution.\n\nIf you can't solve the problem, please open an issue" - " on GitHub." - ) + # instead of raising the error with the small essay they had, just print out the latex error instead + print(output[0].decode("utf-8")) + # # EYHC: This error message is rediculous. Replace it with the actual error message + # raise RuntimeError( + # "Unfortunately, RenderCV's built-in TinyTeX binaries couldn't render" + # " this LaTeX file into a PDF. This could be caused by one of two" + # " reasons:\n\n1- The theme templates might have been updated in a way" + # " RenderCV's TinyTeX cannot render. RenderCV's TinyTeX is minified to" + # " keep the package size small. As a result, it doesn't function like a" + # " general-purpose LaTeX distribution.\n2- Special characters, like" + # " Greek or Chinese letters, that are not compatible with the fonts used" + # " or RenderCV's TinyTeX might have been used.\n\nHowever, this issue" + # " can be resolved quickly. RenderCV allows you to run your own LaTeX" + # " distribution instead of the built-in TinyTeX. This can be done with" + # " the '--use-local-latex-command' option, as shown below:\n\nrendercv" + # " render --use-local-latex-command lualatex John_Doe_CV.yaml\n\nIf you" + # " ensure that the generated LaTeX file can be compiled by your local" + # " LaTeX distribution, RenderCV will work successfully. You can debug" + # " the generated LaTeX file in your LaTeX editor to resolve any bugs." + # " Then, you can start using RenderCV with your local LaTeX" + # " distribution.\n\nIf you can't solve the problem, please open an issue" + # " on GitHub." + # ) else: try: output = output[0].decode("utf-8")